browser/devtools/tilt/test/browser_tilt_zoom.js

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

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

mercurial