Bug 768842 - Inform the <iframe mozbrowser> embedder when Gecko displays an error page. r=mounir
authorJustin Lebar <justin.lebar@gmail.com>
Mon, 02 Jul 2012 08:21:58 -0400
changeset 98118 e248fe5d20f4b674f44e400101f76cb988c01f24
parent 98117 d9892b7747b5942cc300cfa92ccf5c0569e09dde
child 98119 4cd38116f593d7db97fb24d3e9831243ae553c48
push id23024
push userryanvm@gmail.com
push dateMon, 02 Jul 2012 22:29:23 +0000
treeherdermozilla-central@26aa29fdd888 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs768842
milestone16.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 768842 - Inform the <iframe mozbrowser> embedder when Gecko displays an error page. r=mounir
dom/browser-element/BrowserElementChild.js
dom/browser-element/BrowserElementParent.js
dom/browser-element/mochitest/Makefile.in
dom/browser-element/mochitest/browserElement_ErrorSecurity.js
dom/browser-element/mochitest/test_browserElement_inproc_ErrorSecurity.html
dom/browser-element/mochitest/test_browserElement_oop_ErrorSecurity.html
--- a/dom/browser-element/BrowserElementChild.js
+++ b/dom/browser-element/BrowserElementChild.js
@@ -507,16 +507,24 @@ 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) {
+          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'});
       }
     },
 
     onSecurityChange: function(webProgress, request, state) {
       if (webProgress != docShell) {
         return;
       }
 
--- a/dom/browser-element/BrowserElementParent.js
+++ b/dom/browser-element/BrowserElementParent.js
@@ -143,16 +143,17 @@ function BrowserElementParent(frameLoade
   addMessageListener("contextmenu", this._fireCtxMenuEvent);
   addMessageListener("locationchange", this._fireEventFromMsg);
   addMessageListener("loadstart", this._fireEventFromMsg);
   addMessageListener("loadend", this._fireEventFromMsg);
   addMessageListener("titlechange", this._fireEventFromMsg);
   addMessageListener("iconchange", this._fireEventFromMsg);
   addMessageListener("close", this._fireEventFromMsg);
   addMessageListener("securitychange", this._fireEventFromMsg);
+  addMessageListener("error", this._fireEventFromMsg);
   addMessageListener("get-mozapp-manifest-url", this._sendMozAppManifestURL);
   addMessageListener("keyevent", this._fireKeyEvent);
   addMessageListener("showmodalprompt", this._handleShowModalPrompt);
   addMessageListener('got-screenshot', this._gotDOMRequestResult);
   addMessageListener('got-can-go-back', this._gotDOMRequestResult);
   addMessageListener('got-can-go-forward', this._gotDOMRequestResult);
 
   function defineMethod(name, fn) {
--- a/dom/browser-element/mochitest/Makefile.in
+++ b/dom/browser-element/mochitest/Makefile.in
@@ -23,16 +23,18 @@ include $(topsrcdir)/config/rules.mk
 		browserElementTestHelpers.js \
 		test_browserElement_NoAttr.html \
 		test_browserElement_NoPref.html \
 		test_browserElement_NoWhitelist.html \
 		browserElement_LoadEvents.js \
 		test_browserElement_inproc_LoadEvents.html \
 		browserElement_DataURI.js \
 		test_browserElement_inproc_DataURI.html \
+		browserElement_ErrorSecurity.js \
+		test_browserElement_inproc_ErrorSecurity.html \
 		browserElement_Titlechange.js \
 		test_browserElement_inproc_Titlechange.html \
 		browserElement_TopBarrier.js \
 		test_browserElement_inproc_TopBarrier.html \
 		browserElement_Iconchange.js \
 		test_browserElement_inproc_Iconchange.html \
 		browserElement_GetScreenshot.js \
 		test_browserElement_inproc_GetScreenshot.html \
@@ -72,16 +74,17 @@ include $(topsrcdir)/config/rules.mk
 
 # OOP tests don't work on Windows (bug 763081).
 #
 # Note that there's no inproc equivalent of BackForward; that's intentional.
 ifneq ($(OS_ARCH),WINNT)
 _TEST_FILES += \
 		test_browserElement_oop_LoadEvents.html \
 		test_browserElement_oop_DataURI.html \
+		test_browserElement_oop_ErrorSecurity.html \
 		test_browserElement_oop_Titlechange.html \
 		test_browserElement_oop_TopBarrier.html \
 		test_browserElement_oop_Iconchange.html \
 		test_browserElement_oop_GetScreenshot.html \
 		test_browserElement_oop_SetVisible.html \
 		test_browserElement_oop_KeyEvents.html \
 		test_browserElement_oop_Alert.html \
 		test_browserElement_oop_AlertInFrame.html \
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/browserElement_ErrorSecurity.js
@@ -0,0 +1,27 @@
+/* Any copyright is dedicated to the public domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Bug 764718 - Test that mozbrowsererror works for a security error.
+
+"use strict";
+
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+  browserElementTestHelpers.setEnabledPref(true);
+  browserElementTestHelpers.addToWhitelist();
+
+  var iframe = document.createElement('iframe');
+  iframe.mozbrowser = true;
+
+  iframe.addEventListener("mozbrowsererror", function(e) {
+    ok(true, "Got mozbrowsererror event.");
+    ok(e.detail.type, "Event's detail has a |type| param.");
+    SimpleTest.finish();
+  });
+
+  iframe.src = "https://expired.example.com";
+  document.body.appendChild(iframe);
+}
+
+runTest();
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/test_browserElement_inproc_ErrorSecurity.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for mozbrowser</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script type="application/javascript;version=1.7" src="browserElement_ErrorSecurity.js">
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/test_browserElement_oop_ErrorSecurity.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for mozbrowser</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script type="application/javascript;version=1.7" src="browserElement_ErrorSecurity.js">
+</script>
+</body>
+</html>