mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 809290 - Fix nsLocation::CheckURL. r=bz
This commit is contained in:
parent
6f4c5d25ef
commit
bcd798914e
@ -108,31 +108,6 @@ nsLocation::GetDocShell()
|
||||
return docshell;
|
||||
}
|
||||
|
||||
// Try to get the the document corresponding to the given JSScript.
|
||||
static already_AddRefed<nsIDocument>
|
||||
GetScriptDocument(JSContext *cx, JSScript *script)
|
||||
{
|
||||
if (!cx || !script)
|
||||
return nullptr;
|
||||
|
||||
JSObject* scope = JS_GetGlobalFromScript(script);
|
||||
if (!scope)
|
||||
return nullptr;
|
||||
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window =
|
||||
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(cx, scope));
|
||||
if (!window)
|
||||
return nullptr;
|
||||
|
||||
// If it's a window, get its document.
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
window->GetDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
|
||||
return doc.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLocation::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo)
|
||||
{
|
||||
@ -166,13 +141,12 @@ nsLocation::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo)
|
||||
// current URI as the referrer. If they don't match, use the principal's
|
||||
// URI.
|
||||
|
||||
JSScript* script = nullptr;
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
nsCOMPtr<nsIURI> docOriginalURI, docCurrentURI, principalURI;
|
||||
// NB: A false return value from JS_DescribeScriptedCaller means no caller
|
||||
// was found. It does not signal that an exception was thrown.
|
||||
if (JS_DescribeScriptedCaller(cx, &script, nullptr)) {
|
||||
doc = GetScriptDocument(cx, script);
|
||||
nsCOMPtr<nsPIDOMWindow> entryPoint =
|
||||
do_QueryInterface(nsJSUtils::GetDynamicScriptGlobal(cx));
|
||||
if (entryPoint) {
|
||||
doc = entryPoint->GetDoc();
|
||||
}
|
||||
if (doc) {
|
||||
docOriginalURI = doc->GetOriginalURI();
|
||||
|
@ -56,8 +56,15 @@ function iframeLoaded(identifier) {
|
||||
is(iframeCw.getInnerIframeReferrer(), iframeCw.location, 'inner iframe referrer');
|
||||
|
||||
// Now do the test again, this time with a popup.
|
||||
//
|
||||
// NB: in this situation, we're actually getting called in an event handler from
|
||||
// the iframe, meaning that it serves as the script entry point. But that's a detail,
|
||||
// and we want to pretend like this window is doing the call. So let's use setTimeout
|
||||
// to forget about the iframe.
|
||||
window.setTimeout(function() {
|
||||
popup = window.open('file_bug593174_1.html');
|
||||
popup.onload = iframeLoaded('popup/outer');
|
||||
}, 0);
|
||||
}
|
||||
else if (loadCount == 4) {
|
||||
history.replaceState('', '', Math.random());
|
||||
|
Loading…
Reference in New Issue
Block a user