mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1050456 - Part 1: Prevent prerendered pages from showing the slow script dialog; r=bzbarsky
This commit is contained in:
parent
b02950208c
commit
a0e86805c1
@ -11,3 +11,5 @@ support-files =
|
||||
file_focuser.html
|
||||
file_fullScreenPropertyAccessor.html
|
||||
skip-if = e10s # prerendering doesn't work in e10s yet
|
||||
[test_kill_longrunning_prerendered_content.xul]
|
||||
skip-if = e10s # prerendering doesn't work in e10s yet
|
||||
|
@ -0,0 +1,85 @@
|
||||
<?xml version="1.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"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
onload="runTest();">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<script class="testbody" type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function Listener(aBrowser, aPrerendered, aCallback) {
|
||||
this.init(aBrowser, aPrerendered, aCallback);
|
||||
}
|
||||
|
||||
Listener.prototype = {
|
||||
init: function(aBrowser, aCallback) {
|
||||
this.mBrowser = aBrowser;
|
||||
this.mCallback = aCallback;
|
||||
},
|
||||
QueryInterface: function(aIID) {
|
||||
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
|
||||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
|
||||
aIID.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus) {
|
||||
if ((aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP) &&
|
||||
(aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_IS_DOCUMENT)) {
|
||||
setTimeout(this.mCallback, 0);
|
||||
}
|
||||
},
|
||||
onProgressChange : function(aWebProgress, aRequest,
|
||||
aCurSelfProgress, aMaxSelfProgress,
|
||||
aCurTotalProgress, aMaxTotalProgress) {},
|
||||
onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags) {},
|
||||
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) {},
|
||||
onSecurityChange : function(aWebProgress, aRequest, aState) {},
|
||||
mBrowser: null,
|
||||
mPrerendered: false,
|
||||
mCallback: null
|
||||
};
|
||||
|
||||
var progress, progressListener;
|
||||
|
||||
function runTest() {
|
||||
SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["dom.max_script_run_time", 1]
|
||||
]
|
||||
}, function() {
|
||||
test(function() {
|
||||
ok("The page is successfully interrupted.");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function test(aCallback) {
|
||||
var browser = document.getElementById("prerendered");;
|
||||
progressListener = new Listener(browser, aCallback);
|
||||
var docShell = browser.docShell;
|
||||
progress = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIWebProgress);
|
||||
progress.addProgressListener(progressListener,
|
||||
Components.interfaces.nsIWebProgress.NOTIFY_ALL);
|
||||
browser.loadURI("data:text/html,<script>;for(;;);</script" + ">");
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<body id="html_body" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1050456">Mozilla Bug 1050456</a>
|
||||
<p id="display"></p>
|
||||
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
<browser prerendered="true" id="prerendered"/>
|
||||
</window>
|
@ -20,6 +20,7 @@
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIDebug2.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "amIAddonManager.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsPrintfCString.h"
|
||||
@ -1452,6 +1453,14 @@ XPCJSRuntime::InterruptCallback(JSContext *cx)
|
||||
if (!win)
|
||||
return true;
|
||||
|
||||
nsIDocShell* docShell = win->GetDocShell();
|
||||
if (docShell && docShell->GetIsPrerendered()) {
|
||||
// We cannot display a dialog if the page is being prerendered, so
|
||||
// just kill the page.
|
||||
mozilla::dom::HandlePrerenderingViolation(win);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Show the prompt to the user, and kill if requested.
|
||||
nsGlobalWindow::SlowScriptResponse response = win->ShowSlowScriptDialog();
|
||||
if (response == nsGlobalWindow::KillSlowScript)
|
||||
|
Loading…
Reference in New Issue
Block a user