|
1 /* Any copyright is dedicated to the public domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Bug 709759 - Test the stop ability of <iframe mozbrowser>. |
|
5 |
|
6 // The img that is loaded will never be returned and will block |
|
7 // the page from loading, the timeout ensures that the page is |
|
8 // actually blocked from loading, once stop is called the |
|
9 // image load will be cancaelled and mozbrowserloadend should be called. |
|
10 |
|
11 "use strict"; |
|
12 SimpleTest.waitForExplicitFinish(); |
|
13 browserElementTestHelpers.setEnabledPref(true); |
|
14 browserElementTestHelpers.addPermission(); |
|
15 |
|
16 var iframe; |
|
17 var stopped = false; |
|
18 var imgSrc = 'http://test/tests/dom/browser-element/mochitest/file_bug709759.sjs'; |
|
19 |
|
20 function runTest() { |
|
21 iframe = document.createElement('iframe'); |
|
22 SpecialPowers.wrap(iframe).mozbrowser = true; |
|
23 |
|
24 iframe.addEventListener('mozbrowserloadend', loadend); |
|
25 iframe.src = 'data:text/html,<html>' + |
|
26 '<body><img src="' + imgSrc + '" /></body></html>'; |
|
27 |
|
28 document.body.appendChild(iframe); |
|
29 |
|
30 setTimeout(function() { |
|
31 stopped = true; |
|
32 iframe.stop(); |
|
33 }, 200); |
|
34 } |
|
35 |
|
36 function loadend() { |
|
37 ok(stopped, 'Iframes network connections were stopped'); |
|
38 |
|
39 // Wait 1 second and make sure there isn't a mozbrowsererror after stop(); |
|
40 iframe.addEventListener('mozbrowsererror', handleError); |
|
41 window.setTimeout(function() { |
|
42 iframe.removeEventListener('mozbrowsererror', handleError); |
|
43 SimpleTest.finish(); |
|
44 }, 1000); |
|
45 } |
|
46 |
|
47 function handleError() { |
|
48 ok(false, "mozbrowsererror should not be fired"); |
|
49 } |
|
50 |
|
51 addEventListener('testready', runTest); |