mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 291653, make window level listeners work consistently with other listeners, r=jst
This commit is contained in:
parent
41186fd050
commit
122b6baf78
@ -7462,9 +7462,18 @@ nsGlobalWindow::GetListenerManager(bool aCreateIfNotFound)
|
||||
nsIScriptContext*
|
||||
nsGlobalWindow::GetContextForEventHandlers(nsresult* aRv)
|
||||
{
|
||||
nsIScriptContext* scx = GetContext();
|
||||
*aRv = scx ? NS_OK : NS_ERROR_UNEXPECTED;
|
||||
return scx;
|
||||
*aRv = NS_ERROR_UNEXPECTED;
|
||||
if (IsInnerWindow()) {
|
||||
nsPIDOMWindow* outer = GetOuterWindow();
|
||||
NS_ENSURE_TRUE(outer && outer->GetCurrentInnerWindow() == this, nsnull);
|
||||
}
|
||||
|
||||
nsIScriptContext* scx;
|
||||
if ((scx = GetContext())) {
|
||||
*aRv = NS_OK;
|
||||
return scx;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -52,6 +52,8 @@ _TEST_FILES = \
|
||||
test_bug159849.html \
|
||||
test_bug265203.html \
|
||||
test_bug291377.html \
|
||||
file_bug291653.html \
|
||||
test_bug291653.html \
|
||||
test_bug308856.html \
|
||||
test_bug317448.html \
|
||||
test_bug327891.html \
|
||||
|
28
dom/tests/mochitest/bugs/file_bug291653.html
Normal file
28
dom/tests/mochitest/bugs/file_bug291653.html
Normal file
@ -0,0 +1,28 @@
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
<!--
|
||||
function listener1() {
|
||||
window.showModalDialog("data:text/html,<script>var maintest = opener.opener; opener.location = 'data:text/html,test'; maintest.end(); window.close();</script>");
|
||||
}
|
||||
|
||||
function listener2() {
|
||||
opener.secondListenerDidRun = true;
|
||||
}
|
||||
|
||||
window.addEventListener("foo", listener1);
|
||||
window.addEventListener("foo", listener2);
|
||||
|
||||
|
||||
function fireFoo() {
|
||||
var e = document.createEvent("Events");
|
||||
e.initEvent("foo", true, true);
|
||||
window.dispatchEvent(e);
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
</head>
|
||||
<body onload="setTimeout(fireFoo, 0)">
|
||||
Test for bug 291653
|
||||
</body>
|
||||
</html>
|
46
dom/tests/mochitest/bugs/test_bug291653.html
Normal file
46
dom/tests/mochitest/bugs/test_bug291653.html
Normal file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=291653
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 291653</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=291653">Mozilla Bug 291653</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 291653 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var secondListenerDidRun = false;
|
||||
|
||||
var w = window.open("file_bug291653.html", "foo", "width=300,height=300");
|
||||
|
||||
function closeTest() {
|
||||
w.setTimeout("close()", 0);
|
||||
setTimeout("finish()", 500);
|
||||
}
|
||||
|
||||
function finish() {
|
||||
ok(!secondListenerDidRun, "Shouldn't have run second listener!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function end() {
|
||||
setTimeout("closeTest()", 500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user