Bug 836567 - Part 1: Set ResultPrincipalURI to active document's URI before evaluating script. r?bz
MozReview-Commit-ID: CQ5l4Diagy0
--- a/dom/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/jsurl/nsJSProtocolHandler.cpp
@@ -687,16 +687,26 @@ nsJSChannel::EvaluateScript()
// indicate the the request is busy while the script is executing...
// Note that we want to be in the loadgroup and pending while we evaluate
// the script, so that we find out if the loadgroup gets canceled by the
// script execution (in which case we shouldn't pump out data even if the
// script returns it).
if (NS_SUCCEEDED(mStatus)) {
+ nsCOMPtr<nsILoadInfo> loadInfo;
+ mStreamChannel->GetLoadInfo(getter_AddRefs(loadInfo));
+ if (loadInfo) {
+ // Set the channel's resultPrincipalURI to the active document's URI.
+ nsCOMPtr<nsIURI> docURI = mOriginalInnerWindow->GetDocumentURI();
+ if (docURI) {
+ loadInfo->SetResultPrincipalURI(docURI);
+ }
+ }
+
nsresult rv = mIOThunk->EvaluateScript(mStreamChannel, mPopupState,
mExecutionPolicy,
mOriginalInnerWindow);
// Note that evaluation may have canceled us, so recheck mStatus again
if (NS_FAILED(rv) && NS_SUCCEEDED(mStatus)) {
mStatus = rv;
}