зеркало из https://github.com/mozilla/pjs.git
Bug 430276, new XMLHttpRequest() after document.write throws an exception, patch2, r+sr=jst, a=beltzner
This commit is contained in:
Родитель
49cf7082a4
Коммит
93242f36db
|
@ -4785,10 +4785,19 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
|
|||
|
||||
nsCOMPtr<nsIJSNativeInitializer> initializer(do_QueryInterface(native));
|
||||
if (initializer) {
|
||||
// Initialize object using the current inner window, but only if
|
||||
// the caller can access it.
|
||||
nsCOMPtr<nsPIDOMWindow> owner = do_QueryReferent(aWeakOwner);
|
||||
NS_ENSURE_STATE(owner && owner->GetOuterWindow() &&
|
||||
owner->GetOuterWindow()->GetCurrentInnerWindow() == owner);
|
||||
rv = initializer->Initialize(owner, cx, obj, argc, argv);
|
||||
nsPIDOMWindow* outerWindow = owner ? owner->GetOuterWindow() : nsnull;
|
||||
nsPIDOMWindow* currentInner =
|
||||
outerWindow ? outerWindow->GetCurrentInnerWindow() : nsnull;
|
||||
if (!currentInner ||
|
||||
(owner != currentInner &&
|
||||
!nsContentUtils::CanCallerAccess(currentInner))) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
rv = initializer->Initialize(currentInner, cx, obj, argc, argv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ _TEST_FILES = \
|
|||
test_bug414291.html \
|
||||
test_bug430276.html \
|
||||
iframe_bug430276.html \
|
||||
iframe_bug430276-2.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script type="application/javascript">
|
||||
new XMLHttpRequest();
|
||||
function runTest() {
|
||||
document.open();
|
||||
var succeeded = true;
|
||||
try {
|
||||
new XMLHttpRequest();
|
||||
} catch(e) {
|
||||
succeeded = false;
|
||||
}
|
||||
window.parent.ok(succeeded, "Creating XMLHttpRequest failed!");
|
||||
window.parent.SimpleTest.finish();
|
||||
document.close();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="runTest()">
|
||||
</body>
|
||||
</html>
|
|
@ -12,7 +12,7 @@
|
|||
succeeded = false;
|
||||
}
|
||||
window.parent.ok(succeeded, "Creating XMLHttpRequest failed!");
|
||||
window.parent.SimpleTest.finish();
|
||||
window.parent.nextTest();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
@ -25,6 +25,11 @@ function startTest() {
|
|||
.setAttribute("src", "iframe_bug430276.html");
|
||||
}
|
||||
|
||||
function nextTest() {
|
||||
document.getElementById("testFrame")
|
||||
.setAttribute("src", "iframe_bug430276-2.html");
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(startTest);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче