Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
1 /* Any copyright is dedicated to the public domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 // Bug 709759 - Test the stop ability of <iframe mozbrowser>.
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.
11 "use strict";
12 SimpleTest.waitForExplicitFinish();
13 browserElementTestHelpers.setEnabledPref(true);
14 browserElementTestHelpers.addPermission();
16 var iframe;
17 var stopped = false;
18 var imgSrc = 'http://test/tests/dom/browser-element/mochitest/file_bug709759.sjs';
20 function runTest() {
21 iframe = document.createElement('iframe');
22 SpecialPowers.wrap(iframe).mozbrowser = true;
24 iframe.addEventListener('mozbrowserloadend', loadend);
25 iframe.src = 'data:text/html,<html>' +
26 '<body><img src="' + imgSrc + '" /></body></html>';
28 document.body.appendChild(iframe);
30 setTimeout(function() {
31 stopped = true;
32 iframe.stop();
33 }, 200);
34 }
36 function loadend() {
37 ok(stopped, 'Iframes network connections were stopped');
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 }
47 function handleError() {
48 ok(false, "mozbrowsererror should not be fired");
49 }
51 addEventListener('testready', runTest);