Wed, 31 Dec 2014 07:53:36 +0100
Correct small whitespace inconsistency, lost while renaming variables.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3 "use strict";
5 const ZOOM = 2;
6 const RESIZE = 50;
7 let tiltOpened = false;
9 function test() {
10 if (!isTiltEnabled()) {
11 info("Skipping controller test because Tilt isn't enabled.");
12 return;
13 }
14 if (!isWebGLSupported()) {
15 info("Skipping controller test because WebGL isn't supported.");
16 return;
17 }
19 waitForExplicitFinish();
21 createTab(function() {
22 TiltUtils.setDocumentZoom(window, ZOOM);
24 createTilt({
25 onTiltOpen: function(instance)
26 {
27 tiltOpened = true;
29 ok(isApprox(instance.presenter._getPageZoom(), ZOOM),
30 "The Highlighter zoom doesn't have the expected results.");
32 ok(isApprox(instance.presenter.transforms.zoom, ZOOM),
33 "The presenter transforms zoom wasn't initially set correctly.");
35 let contentWindow = gBrowser.selectedBrowser.contentWindow;
36 let initialWidth = contentWindow.innerWidth;
37 let initialHeight = contentWindow.innerHeight;
39 let renderer = instance.presenter._renderer;
40 let arcball = instance.controller.arcball;
42 ok(isApprox(contentWindow.innerWidth * ZOOM, renderer.width, 1),
43 "The renderer width wasn't set correctly before the resize.");
44 ok(isApprox(contentWindow.innerHeight * ZOOM, renderer.height, 1),
45 "The renderer height wasn't set correctly before the resize.");
47 ok(isApprox(contentWindow.innerWidth * ZOOM, arcball.width, 1),
48 "The arcball width wasn't set correctly before the resize.");
49 ok(isApprox(contentWindow.innerHeight * ZOOM, arcball.height, 1),
50 "The arcball height wasn't set correctly before the resize.");
53 window.resizeBy(-RESIZE * ZOOM, -RESIZE * ZOOM);
55 executeSoon(function() {
56 ok(isApprox(contentWindow.innerWidth + RESIZE, initialWidth, 1),
57 "The content window width wasn't set correctly after the resize.");
58 ok(isApprox(contentWindow.innerHeight + RESIZE, initialHeight, 1),
59 "The content window height wasn't set correctly after the resize.");
61 ok(isApprox(contentWindow.innerWidth * ZOOM, renderer.width, 1),
62 "The renderer width wasn't set correctly after the resize.");
63 ok(isApprox(contentWindow.innerHeight * ZOOM, renderer.height, 1),
64 "The renderer height wasn't set correctly after the resize.");
66 ok(isApprox(contentWindow.innerWidth * ZOOM, arcball.width, 1),
67 "The arcball width wasn't set correctly after the resize.");
68 ok(isApprox(contentWindow.innerHeight * ZOOM, arcball.height, 1),
69 "The arcball height wasn't set correctly after the resize.");
72 window.resizeBy(RESIZE * ZOOM, RESIZE * ZOOM);
75 Services.obs.addObserver(cleanup, DESTROYED, false);
76 Tilt.destroy(Tilt.currentWindowId);
77 });
78 }
79 }, false, function suddenDeath()
80 {
81 info("Tilt could not be initialized properly.");
82 cleanup();
83 });
84 });
85 }
87 function cleanup() {
88 if (tiltOpened) { Services.obs.removeObserver(cleanup, DESTROYED); }
89 gBrowser.removeCurrentTab();
90 finish();
91 }