1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/tilt/test/browser_tilt_zoom.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 +"use strict"; 1.7 + 1.8 +const ZOOM = 2; 1.9 +const RESIZE = 50; 1.10 +let tiltOpened = false; 1.11 + 1.12 +function test() { 1.13 + if (!isTiltEnabled()) { 1.14 + info("Skipping controller test because Tilt isn't enabled."); 1.15 + return; 1.16 + } 1.17 + if (!isWebGLSupported()) { 1.18 + info("Skipping controller test because WebGL isn't supported."); 1.19 + return; 1.20 + } 1.21 + 1.22 + waitForExplicitFinish(); 1.23 + 1.24 + createTab(function() { 1.25 + TiltUtils.setDocumentZoom(window, ZOOM); 1.26 + 1.27 + createTilt({ 1.28 + onTiltOpen: function(instance) 1.29 + { 1.30 + tiltOpened = true; 1.31 + 1.32 + ok(isApprox(instance.presenter._getPageZoom(), ZOOM), 1.33 + "The Highlighter zoom doesn't have the expected results."); 1.34 + 1.35 + ok(isApprox(instance.presenter.transforms.zoom, ZOOM), 1.36 + "The presenter transforms zoom wasn't initially set correctly."); 1.37 + 1.38 + let contentWindow = gBrowser.selectedBrowser.contentWindow; 1.39 + let initialWidth = contentWindow.innerWidth; 1.40 + let initialHeight = contentWindow.innerHeight; 1.41 + 1.42 + let renderer = instance.presenter._renderer; 1.43 + let arcball = instance.controller.arcball; 1.44 + 1.45 + ok(isApprox(contentWindow.innerWidth * ZOOM, renderer.width, 1), 1.46 + "The renderer width wasn't set correctly before the resize."); 1.47 + ok(isApprox(contentWindow.innerHeight * ZOOM, renderer.height, 1), 1.48 + "The renderer height wasn't set correctly before the resize."); 1.49 + 1.50 + ok(isApprox(contentWindow.innerWidth * ZOOM, arcball.width, 1), 1.51 + "The arcball width wasn't set correctly before the resize."); 1.52 + ok(isApprox(contentWindow.innerHeight * ZOOM, arcball.height, 1), 1.53 + "The arcball height wasn't set correctly before the resize."); 1.54 + 1.55 + 1.56 + window.resizeBy(-RESIZE * ZOOM, -RESIZE * ZOOM); 1.57 + 1.58 + executeSoon(function() { 1.59 + ok(isApprox(contentWindow.innerWidth + RESIZE, initialWidth, 1), 1.60 + "The content window width wasn't set correctly after the resize."); 1.61 + ok(isApprox(contentWindow.innerHeight + RESIZE, initialHeight, 1), 1.62 + "The content window height wasn't set correctly after the resize."); 1.63 + 1.64 + ok(isApprox(contentWindow.innerWidth * ZOOM, renderer.width, 1), 1.65 + "The renderer width wasn't set correctly after the resize."); 1.66 + ok(isApprox(contentWindow.innerHeight * ZOOM, renderer.height, 1), 1.67 + "The renderer height wasn't set correctly after the resize."); 1.68 + 1.69 + ok(isApprox(contentWindow.innerWidth * ZOOM, arcball.width, 1), 1.70 + "The arcball width wasn't set correctly after the resize."); 1.71 + ok(isApprox(contentWindow.innerHeight * ZOOM, arcball.height, 1), 1.72 + "The arcball height wasn't set correctly after the resize."); 1.73 + 1.74 + 1.75 + window.resizeBy(RESIZE * ZOOM, RESIZE * ZOOM); 1.76 + 1.77 + 1.78 + Services.obs.addObserver(cleanup, DESTROYED, false); 1.79 + Tilt.destroy(Tilt.currentWindowId); 1.80 + }); 1.81 + } 1.82 + }, false, function suddenDeath() 1.83 + { 1.84 + info("Tilt could not be initialized properly."); 1.85 + cleanup(); 1.86 + }); 1.87 + }); 1.88 +} 1.89 + 1.90 +function cleanup() { 1.91 + if (tiltOpened) { Services.obs.removeObserver(cleanup, DESTROYED); } 1.92 + gBrowser.removeCurrentTab(); 1.93 + finish(); 1.94 +}