Bug 816452 - Don't fire mozbrowsererror when loading page is stopped. r=jlebar
authorPatrick Wang <kk1fff@patrickz.net>
Wed, 05 Dec 2012 16:10:19 +0800
changeset 115146 20e8cde489bae20822b1ded0b64fedac1d3f8fd3
parent 115145 f3ef58ba9e55d4ce808150ea8d469861c3067cf0
child 115147 496577951cc2b307c04ddae00959bfe2a3990586
push id23973
push useremorley@mozilla.com
push dateThu, 06 Dec 2012 10:04:18 +0000
treeherdermozilla-central@ddda5400c826 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlebar
bugs816452
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 816452 - Don't fire mozbrowsererror when loading page is stopped. r=jlebar
dom/browser-element/BrowserElementChild.js
dom/browser-element/mochitest/browserElement_Stop.js
--- a/dom/browser-element/BrowserElementChild.js
+++ b/dom/browser-element/BrowserElementChild.js
@@ -719,17 +719,20 @@ BrowserElementChild.prototype = {
       if (stateFlags & Ci.nsIWebProgressListener.STATE_START) {
         this._seenLoadStart = true;
         sendAsyncMsg('loadstart');
       }
 
       if (stateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
         sendAsyncMsg('loadend');
 
-        if (status == Cr.NS_OK) {
+        // Ignoring NS_BINDING_ABORTED, which is set when loading page is
+        // stopped.
+        if (status == Cr.NS_OK ||
+            status == Cr.NS_BINDING_ABORTED) {
           return;
         }
 
         // TODO See nsDocShell::DisplayLoadError for a list of all the error
         // codes (the status param) we should eventually handle here.
         sendAsyncMsg('error', {type: 'other'});
       }
     },
--- a/dom/browser-element/mochitest/browserElement_Stop.js
+++ b/dom/browser-element/mochitest/browserElement_Stop.js
@@ -31,12 +31,22 @@ function runTest() {
   setTimeout(function() {
     stopped = true;
     iframe.stop();
   }, 200);
 }
 
 function loadend() {
   ok(stopped, 'Iframes network connections were stopped');
-  SimpleTest.finish();
+
+  // Wait 1 second and make sure there isn't a mozbrowsererror after stop();
+  iframe.addEventListener('mozbrowsererror', handleError);
+  window.setTimeout(function() {
+    iframe.removeEventListener('mozbrowsererror', handleError);
+    SimpleTest.finish();
+  }, 1000);
+}
+
+function handleError() {
+  ok(false, "mozbrowsererror should not be fired");
 }
 
 runTest();