зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1366808: Add tests for about:restartrequired page. r=felipe
This commit is contained in:
Родитель
339982e013
Коммит
48e98b6ec3
|
@ -1,3 +1,4 @@
|
|||
[DEFAULT]
|
||||
|
||||
[test_aboutCrashed.xul]
|
||||
[test_aboutRestartRequired.xul]
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
||||
<iframe type="content" id="frame1"/>
|
||||
<iframe type="content" id="frame2" onload="doTest()"/>
|
||||
<script type="application/javascript"><![CDATA[
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// Load error pages do not fire "load" events, so let's use a progressListener.
|
||||
function waitForErrorPage(frame) {
|
||||
return new Promise(resolve => {
|
||||
let progressListener = {
|
||||
onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {
|
||||
if (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) {
|
||||
frame.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebProgress)
|
||||
.removeProgressListener(progressListener,
|
||||
Ci.nsIWebProgress.NOTIFY_LOCATION);
|
||||
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference])
|
||||
};
|
||||
|
||||
frame.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebProgress)
|
||||
.addProgressListener(progressListener,
|
||||
Ci.nsIWebProgress.NOTIFY_LOCATION);
|
||||
});
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
(async function testBody() {
|
||||
let frame1 = document.getElementById("frame1");
|
||||
let frame2 = document.getElementById("frame2");
|
||||
let uri1 = Services.io.newURI("http://www.example.com/1");
|
||||
let uri2 = Services.io.newURI("http://www.example.com/2");
|
||||
|
||||
let errorPageReady = waitForErrorPage(frame1);
|
||||
frame1.docShell.displayLoadError(Cr.NS_ERROR_BUILDID_MISMATCH, uri1, null);
|
||||
|
||||
await errorPageReady;
|
||||
frame1.docShell.chromeEventHandler.removeAttribute("crashedPageTitle");
|
||||
|
||||
SimpleTest.is(frame1.contentDocument.documentURI,
|
||||
"about:restartrequired?e=restartrequired&u=http%3A//www.example.com/1&c=UTF-8&f=regular&d=%20",
|
||||
"Correct about:restartrequired displayed for page with title.");
|
||||
|
||||
errorPageReady = waitForErrorPage(frame2);
|
||||
frame2.docShell.displayLoadError(Cr.NS_ERROR_BUILDID_MISMATCH, uri2, null);
|
||||
|
||||
await errorPageReady;
|
||||
|
||||
SimpleTest.is(frame2.contentDocument.documentURI,
|
||||
"about:restartrequired?e=restartrequired&u=http%3A//www.example.com/2&c=UTF-8&f=regular&d=%20",
|
||||
"Correct about:restartrequired displayed for page with no title.");
|
||||
|
||||
SimpleTest.finish();
|
||||
})().catch(ex => SimpleTest.ok(false, ex));
|
||||
}
|
||||
]]></script>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;" />
|
||||
</window>
|
|
@ -9,4 +9,5 @@ support-files =
|
|||
skip-if = (os == "linux") # Bug 1383315
|
||||
[browser_showForm.js]
|
||||
[browser_shown.js]
|
||||
[browser_shownRestartRequired.js]
|
||||
[browser_withoutDump.js]
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
"use strict";
|
||||
|
||||
const PAGE =
|
||||
"data:text/html,<html><body>A%20regular,%20everyday,%20normal%20page.";
|
||||
|
||||
/**
|
||||
* This function returns a Promise that resolves once the following
|
||||
* actions have taken place:
|
||||
*
|
||||
* 1) A new tab is opened up at PAGE
|
||||
* 2) The tab is crashed
|
||||
* 3) The about:restartrequired page is displayed
|
||||
*
|
||||
* @returns Promise
|
||||
*/
|
||||
function crashTabTestHelper() {
|
||||
return BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: PAGE,
|
||||
}, async function(browser) {
|
||||
// Simulate buildID mismatch.
|
||||
TabCrashHandler.testBuildIDMismatch = true;
|
||||
|
||||
await BrowserTestUtils.crashBrowser(browser, false);
|
||||
let doc = browser.contentDocument;
|
||||
|
||||
// Since about:restartRequired will run in the parent process, we can safely
|
||||
// manipulate its DOM nodes directly
|
||||
let title = doc.getElementById("title");
|
||||
let description = doc.getElementById("errorLongContent");
|
||||
let restartButton = doc.getElementById("restart");
|
||||
|
||||
ok(title, "Title element exists.");
|
||||
ok(description, "Description element exists.");
|
||||
ok(restartButton, "Restart button exists.");
|
||||
|
||||
// Reset
|
||||
TabCrashHandler.testBuildIDMismatch = false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the about:restartrequired page appears when buildID mismatches
|
||||
* between parent and child processes are encountered.
|
||||
*/
|
||||
add_task(async function test_default() {
|
||||
await crashTabTestHelper();
|
||||
});
|
|
@ -74,6 +74,7 @@ var TabCrashHandler = {
|
|||
browserMap: new BrowserWeakMap(),
|
||||
unseenCrashedChildIDs: [],
|
||||
crashedBrowserQueues: new Map(),
|
||||
testBuildIDMismatch: false,
|
||||
|
||||
get prefs() {
|
||||
delete this.prefs;
|
||||
|
@ -225,7 +226,7 @@ var TabCrashHandler = {
|
|||
for (let weakBrowser of browserQueue) {
|
||||
let browser = weakBrowser.browser.get();
|
||||
if (browser) {
|
||||
if (weakBrowser.restartRequired) {
|
||||
if (weakBrowser.restartRequired || this.testBuildIDMismatch) {
|
||||
this.sendToRestartRequiredPage(browser);
|
||||
} else {
|
||||
this.sendToTabCrashedPage(browser);
|
||||
|
|
Загрузка…
Ссылка в новой задаче