michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: "use strict"; michael@0: michael@0: const ZOOM = 2; michael@0: const RESIZE = 50; michael@0: let tiltOpened = false; michael@0: michael@0: function test() { michael@0: if (!isTiltEnabled()) { michael@0: info("Skipping controller test because Tilt isn't enabled."); michael@0: return; michael@0: } michael@0: if (!isWebGLSupported()) { michael@0: info("Skipping controller test because WebGL isn't supported."); michael@0: return; michael@0: } michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: createTab(function() { michael@0: TiltUtils.setDocumentZoom(window, ZOOM); michael@0: michael@0: createTilt({ michael@0: onTiltOpen: function(instance) michael@0: { michael@0: tiltOpened = true; michael@0: michael@0: ok(isApprox(instance.presenter._getPageZoom(), ZOOM), michael@0: "The Highlighter zoom doesn't have the expected results."); michael@0: michael@0: ok(isApprox(instance.presenter.transforms.zoom, ZOOM), michael@0: "The presenter transforms zoom wasn't initially set correctly."); michael@0: michael@0: let contentWindow = gBrowser.selectedBrowser.contentWindow; michael@0: let initialWidth = contentWindow.innerWidth; michael@0: let initialHeight = contentWindow.innerHeight; michael@0: michael@0: let renderer = instance.presenter._renderer; michael@0: let arcball = instance.controller.arcball; michael@0: michael@0: ok(isApprox(contentWindow.innerWidth * ZOOM, renderer.width, 1), michael@0: "The renderer width wasn't set correctly before the resize."); michael@0: ok(isApprox(contentWindow.innerHeight * ZOOM, renderer.height, 1), michael@0: "The renderer height wasn't set correctly before the resize."); michael@0: michael@0: ok(isApprox(contentWindow.innerWidth * ZOOM, arcball.width, 1), michael@0: "The arcball width wasn't set correctly before the resize."); michael@0: ok(isApprox(contentWindow.innerHeight * ZOOM, arcball.height, 1), michael@0: "The arcball height wasn't set correctly before the resize."); michael@0: michael@0: michael@0: window.resizeBy(-RESIZE * ZOOM, -RESIZE * ZOOM); michael@0: michael@0: executeSoon(function() { michael@0: ok(isApprox(contentWindow.innerWidth + RESIZE, initialWidth, 1), michael@0: "The content window width wasn't set correctly after the resize."); michael@0: ok(isApprox(contentWindow.innerHeight + RESIZE, initialHeight, 1), michael@0: "The content window height wasn't set correctly after the resize."); michael@0: michael@0: ok(isApprox(contentWindow.innerWidth * ZOOM, renderer.width, 1), michael@0: "The renderer width wasn't set correctly after the resize."); michael@0: ok(isApprox(contentWindow.innerHeight * ZOOM, renderer.height, 1), michael@0: "The renderer height wasn't set correctly after the resize."); michael@0: michael@0: ok(isApprox(contentWindow.innerWidth * ZOOM, arcball.width, 1), michael@0: "The arcball width wasn't set correctly after the resize."); michael@0: ok(isApprox(contentWindow.innerHeight * ZOOM, arcball.height, 1), michael@0: "The arcball height wasn't set correctly after the resize."); michael@0: michael@0: michael@0: window.resizeBy(RESIZE * ZOOM, RESIZE * ZOOM); michael@0: michael@0: michael@0: Services.obs.addObserver(cleanup, DESTROYED, false); michael@0: Tilt.destroy(Tilt.currentWindowId); michael@0: }); michael@0: } michael@0: }, false, function suddenDeath() michael@0: { michael@0: info("Tilt could not be initialized properly."); michael@0: cleanup(); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function cleanup() { michael@0: if (tiltOpened) { Services.obs.removeObserver(cleanup, DESTROYED); } michael@0: gBrowser.removeCurrentTab(); michael@0: finish(); michael@0: }