1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/browser-element/mochitest/browserElement_BrowserWindowResize.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +/* Any copyright is dedicated to the public domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Bug 891763 - Test the mozbrowserresize event 1.8 +"use strict"; 1.9 + 1.10 +SimpleTest.waitForExplicitFinish(); 1.11 +browserElementTestHelpers.setEnabledPref(true); 1.12 +browserElementTestHelpers.addPermission(); 1.13 + 1.14 +function runTest() { 1.15 + var srcResizeTo = "data:text/html, \ 1.16 + <script type='application/javascript'> \ 1.17 + window.resizeTo(300, 300); \ 1.18 + <\/script> \ 1.19 + "; 1.20 + 1.21 + var srcResizeBy = "data:text/html, \ 1.22 + <script type='application/javascript'> \ 1.23 + window.resizeBy(-100, -100); \ 1.24 + <\/script> \ 1.25 + "; 1.26 + 1.27 + var count = 0; 1.28 + function checkSize(iframe) { 1.29 + count++; 1.30 + is(iframe.clientWidth, 400, "iframe width does not change"); 1.31 + is(iframe.clientHeight, 400, "iframe height does not change"); 1.32 + if (count == 2) { 1.33 + SimpleTest.finish(); 1.34 + } 1.35 + } 1.36 + 1.37 + function testIFrameWithSrc(src) { 1.38 + var iframe = document.createElement('iframe'); 1.39 + SpecialPowers.wrap(iframe).mozbrowser = true; 1.40 + iframe.style = "border:none; width:400px; height:400px;"; 1.41 + iframe.src = src; 1.42 + iframe.addEventListener("mozbrowserresize", function (e) { 1.43 + is(e.detail.width, 300, "Received correct resize event width"); 1.44 + is(e.detail.height, 300, "Received correct resize event height"); 1.45 + SimpleTest.executeSoon(checkSize.bind(undefined, iframe)); 1.46 + }); 1.47 + document.body.appendChild(iframe); 1.48 + } 1.49 + 1.50 + testIFrameWithSrc(srcResizeTo); 1.51 + testIFrameWithSrc(srcResizeBy); 1.52 +} 1.53 + 1.54 +addEventListener('testready', runTest);