Fix occasional crashes in canvas getImageData and other places

In some places we allocate custom array objects and in the constructor we call
setArrayType, which will allocate the array's data through the GC. In all of
these cases we need to make sure that the array object itself is protected from
garbage collection, because while in the constructor it may not be yet in the
scope the callee has usually set up.

Change-Id: I96b7af4ae00fd809067e12bacd6563984c5e9240
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Fix canvas tests after commit 439f31f128e70ecae16544ee7041695c60e0b2d6

We must make sure that the canvas is created somewhere in the item hierarchy of
a scene-graph initialized (thus visible) window. A Window { visible: true }
type of item is not sufficient, but we can simply use our testcase as
parent/associated item, because that one is equipped with a when: windowShown
condition.

Change-Id: I67a65208fae1a6fd953493eaa2898a324a6cc917
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>