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