dom/browser-element/mochitest/browserElement_BrowserWindowResize.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* Any copyright is dedicated to the public domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 // Bug 891763 - Test the mozbrowserresize event
michael@0 5 "use strict";
michael@0 6
michael@0 7 SimpleTest.waitForExplicitFinish();
michael@0 8 browserElementTestHelpers.setEnabledPref(true);
michael@0 9 browserElementTestHelpers.addPermission();
michael@0 10
michael@0 11 function runTest() {
michael@0 12 var srcResizeTo = "data:text/html, \
michael@0 13 <script type='application/javascript'> \
michael@0 14 window.resizeTo(300, 300); \
michael@0 15 <\/script> \
michael@0 16 ";
michael@0 17
michael@0 18 var srcResizeBy = "data:text/html, \
michael@0 19 <script type='application/javascript'> \
michael@0 20 window.resizeBy(-100, -100); \
michael@0 21 <\/script> \
michael@0 22 ";
michael@0 23
michael@0 24 var count = 0;
michael@0 25 function checkSize(iframe) {
michael@0 26 count++;
michael@0 27 is(iframe.clientWidth, 400, "iframe width does not change");
michael@0 28 is(iframe.clientHeight, 400, "iframe height does not change");
michael@0 29 if (count == 2) {
michael@0 30 SimpleTest.finish();
michael@0 31 }
michael@0 32 }
michael@0 33
michael@0 34 function testIFrameWithSrc(src) {
michael@0 35 var iframe = document.createElement('iframe');
michael@0 36 SpecialPowers.wrap(iframe).mozbrowser = true;
michael@0 37 iframe.style = "border:none; width:400px; height:400px;";
michael@0 38 iframe.src = src;
michael@0 39 iframe.addEventListener("mozbrowserresize", function (e) {
michael@0 40 is(e.detail.width, 300, "Received correct resize event width");
michael@0 41 is(e.detail.height, 300, "Received correct resize event height");
michael@0 42 SimpleTest.executeSoon(checkSize.bind(undefined, iframe));
michael@0 43 });
michael@0 44 document.body.appendChild(iframe);
michael@0 45 }
michael@0 46
michael@0 47 testIFrameWithSrc(srcResizeTo);
michael@0 48 testIFrameWithSrc(srcResizeBy);
michael@0 49 }
michael@0 50
michael@0 51 addEventListener('testready', runTest);

mercurial