diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 2777201d952a..47c6af2e771a 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -1078,7 +1078,7 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther, // When we swap docShells, maybe we have to deal with a new page created just // for this operation. In this case, the browser code should already have set - // the correct userContextId attribute value in the owning XULElement, but our + // the correct userContextId attribute value in the owning element, but our // docShell, that has been created way before) doesn't know that that // happened. // This is the reason why now we must retrieve the correct value from the @@ -1501,7 +1501,7 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther, // When we swap docShells, maybe we have to deal with a new page created just // for this operation. In this case, the browser code should already have set - // the correct userContextId attribute value in the owning XULElement, but our + // the correct userContextId attribute value in the owning element, but our // docShell, that has been created way before) doesn't know that that // happened. // This is the reason why now we must retrieve the correct value from the @@ -2183,7 +2183,7 @@ nsFrameLoader::MaybeCreateDocShell() } ApplySandboxFlags(sandboxFlags); - // Grab the userContextId from owner if XUL + // Grab the userContextId from owner nsresult rv = PopulateUserContextIdFromAttribute(attrs); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -3372,10 +3372,10 @@ nsFrameLoader::PopulateUserContextIdFromAttribute(OriginAttributes& aAttr) { if (aAttr.mUserContextId == nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID) { - // Grab the userContextId from owner if XUL + // Grab the userContextId from owner if XUL or mozbrowser frame nsAutoString userContextIdStr; int32_t namespaceID = mOwnerContent->GetNameSpaceID(); - if ((namespaceID == kNameSpaceID_XUL) && + if ((namespaceID == kNameSpaceID_XUL || OwnerIsMozBrowserFrame()) && mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::usercontextid, userContextIdStr) && !userContextIdStr.IsEmpty()) { diff --git a/dom/base/test/chrome/window_swapFrameLoaders.xul b/dom/base/test/chrome/window_swapFrameLoaders.xul index 8b87f9f704de..8cc3a74ab20f 100644 --- a/dom/base/test/chrome/window_swapFrameLoaders.xul +++ b/dom/base/test/chrome/window_swapFrameLoaders.xul @@ -29,10 +29,12 @@ Test swapFrameLoaders with different frame types and remoteness ["xul", "html"], ["html", "xul"], ["html", "html"], - ["xul", "xul", "remote"], - ["xul", "html", "remote"], - ["html", "xul", "remote"], - ["html", "html", "remote"], + ["xul", "xul", { remote: true }], + ["xul", "html", { remote: true }], + ["html", "xul", { remote: true }], + ["html", "html", { remote: true }], + ["xul", "html", { userContextId: 2 }], + ["xul", "html", { userContextId: 2, remote: true }], ]; const HEIGHTS = [ @@ -69,12 +71,17 @@ Test swapFrameLoaders with different frame types and remoteness }); } - async function addFrame(type, remote, height) { + async function addFrame(type, options, height) { + let remote = options && options.remote; + let userContextId = options && options.userContextId; let frame = document.createElementNS(NS[type], TAG[type]); frame.setAttribute("remote", remote); if (remote && type == "xul") { frame.setAttribute("style", "-moz-binding: none;"); } + if (userContextId) { + frame.setAttribute("usercontextid", userContextId); + } if (type == "html") { frame.setAttribute("mozbrowser", "true"); frame.setAttribute("noisolation", "true"); @@ -99,15 +106,14 @@ Test swapFrameLoaders with different frame types and remoteness add_task(async function() { for (let scenario of SCENARIOS) { - let [ typeA, typeB, remote ] = scenario; - remote = !!remote; + let [ typeA, typeB, options ] = scenario; let heightA = HEIGHTS[0]; - info(`Adding frame A, type ${typeA}, remote ${remote}, height ${heightA}`); - let frameA = await addFrame(typeA, remote, heightA); + info(`Adding frame A, type ${typeA}, options ${JSON.stringify(options)}, height ${heightA}`); + let frameA = await addFrame(typeA, options, heightA); let heightB = HEIGHTS[1]; - info(`Adding frame B, type ${typeB}, remote ${remote}, height ${heightB}`); - let frameB = await addFrame(typeB, remote, heightB); + info(`Adding frame B, type ${typeB}, options ${JSON.stringify(options)}, height ${heightB}`); + let frameB = await addFrame(typeB, options, heightB); let frameScriptFactory = function(name) { return `function() {