browser/base/content/test/chrome/test_aboutCrashed.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 5
michael@0 6 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
michael@0 7 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
michael@0 8
michael@0 9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 10 <script type="application/javascript"
michael@0 11 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
michael@0 12 <iframe type="content" id="frame1"/>
michael@0 13 <iframe type="content" id="frame2" onload="doTest()"/>
michael@0 14 <script type="application/javascript"><![CDATA[
michael@0 15 const Ci = Components.interfaces;
michael@0 16 const Cu = Components.utils;
michael@0 17
michael@0 18 Cu.import("resource://gre/modules/Services.jsm");
michael@0 19 Cu.import("resource://gre/modules/Task.jsm");
michael@0 20 Cu.import("resource://gre/modules/Promise.jsm");
michael@0 21 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
michael@0 22
michael@0 23 SimpleTest.waitForExplicitFinish();
michael@0 24
michael@0 25 // Load error pages do not fire "load" events, so let's use a progressListener.
michael@0 26 function waitForErrorPage(frame) {
michael@0 27 let errorPageDeferred = Promise.defer();
michael@0 28
michael@0 29 let progressListener = {
michael@0 30 onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {
michael@0 31 if (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) {
michael@0 32 frame.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
michael@0 33 .getInterface(Ci.nsIWebProgress)
michael@0 34 .removeProgressListener(progressListener,
michael@0 35 Ci.nsIWebProgress.NOTIFY_LOCATION);
michael@0 36
michael@0 37 errorPageDeferred.resolve();
michael@0 38 }
michael@0 39 },
michael@0 40
michael@0 41 QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
michael@0 42 Ci.nsISupportsWeakReference])
michael@0 43 };
michael@0 44
michael@0 45 frame.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
michael@0 46 .getInterface(Ci.nsIWebProgress)
michael@0 47 .addProgressListener(progressListener,
michael@0 48 Ci.nsIWebProgress.NOTIFY_LOCATION);
michael@0 49
michael@0 50 return errorPageDeferred.promise;
michael@0 51 }
michael@0 52
michael@0 53 function doTest() {
michael@0 54 Task.spawn(function test_aboutCrashed() {
michael@0 55 let frame1 = document.getElementById("frame1");
michael@0 56 let frame2 = document.getElementById("frame2");
michael@0 57 let uri1 = Services.io.newURI("http://www.example.com/1", null, null);
michael@0 58 let uri2 = Services.io.newURI("http://www.example.com/2", null, null);
michael@0 59
michael@0 60 let errorPageReady = waitForErrorPage(frame1);
michael@0 61 frame1.docShell.chromeEventHandler.setAttribute("crashedPageTitle", "pageTitle");
michael@0 62 frame1.docShell.displayLoadError(Components.results.NS_ERROR_CONTENT_CRASHED, uri1, null);
michael@0 63
michael@0 64 yield errorPageReady;
michael@0 65 frame1.docShell.chromeEventHandler.removeAttribute("crashedPageTitle");
michael@0 66
michael@0 67 SimpleTest.is(frame1.contentDocument.documentURI,
michael@0 68 "about:tabcrashed?e=tabcrashed&u=http%3A//www.example.com/1&c=UTF-8&f=regular&d=pageTitle",
michael@0 69 "Correct about:tabcrashed displayed for page with title.");
michael@0 70
michael@0 71 errorPageReady = waitForErrorPage(frame2);
michael@0 72 frame2.docShell.displayLoadError(Components.results.NS_ERROR_CONTENT_CRASHED, uri2, null);
michael@0 73
michael@0 74 yield errorPageReady;
michael@0 75
michael@0 76 SimpleTest.is(frame2.contentDocument.documentURI,
michael@0 77 "about:tabcrashed?e=tabcrashed&u=http%3A//www.example.com/2&c=UTF-8&f=regular&d=%20",
michael@0 78 "Correct about:tabcrashed displayed for page with no title.");
michael@0 79
michael@0 80 SimpleTest.finish();
michael@0 81 });
michael@0 82 }
michael@0 83 ]]></script>
michael@0 84
michael@0 85 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;" />
michael@0 86 </window>

mercurial