|
1 /* Any copyright is dedicated to the public domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Bug 891763 - Test the mozbrowserresize event |
|
5 "use strict"; |
|
6 |
|
7 SimpleTest.waitForExplicitFinish(); |
|
8 browserElementTestHelpers.setEnabledPref(true); |
|
9 browserElementTestHelpers.addPermission(); |
|
10 |
|
11 function runTest() { |
|
12 var srcResizeTo = "data:text/html, \ |
|
13 <script type='application/javascript'> \ |
|
14 window.resizeTo(300, 300); \ |
|
15 <\/script> \ |
|
16 "; |
|
17 |
|
18 var srcResizeBy = "data:text/html, \ |
|
19 <script type='application/javascript'> \ |
|
20 window.resizeBy(-100, -100); \ |
|
21 <\/script> \ |
|
22 "; |
|
23 |
|
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 } |
|
33 |
|
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 } |
|
46 |
|
47 testIFrameWithSrc(srcResizeTo); |
|
48 testIFrameWithSrc(srcResizeBy); |
|
49 } |
|
50 |
|
51 addEventListener('testready', runTest); |