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