mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-07 15:12:28 +00:00
Backed out changeset 82ca028b0524 (bug 1503984) for StaticPrefList failures CLOSED TREE
This commit is contained in:
parent
32f32b7a86
commit
b13992b643
@ -99,9 +99,7 @@ bool WindowNamedPropertiesHandler::getOwnPropDescriptor(
|
||||
|
||||
// Grab the DOM window.
|
||||
nsGlobalWindowInner* win = xpc::WindowGlobalOrNull(aProxy);
|
||||
if (win->Length(nsContentUtils::IsSystemCaller(aCx)
|
||||
? CallerType::System
|
||||
: CallerType::NonSystem) > 0) {
|
||||
if (win->Length() > 0) {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> childWin = win->GetChildWindow(str);
|
||||
if (childWin && ShouldExposeChildWindow(str, childWin)) {
|
||||
// We found a subframe of the right name. Shadowing via |var foo| in
|
||||
|
@ -2635,8 +2635,8 @@ nsDOMWindowList* nsGlobalWindowInner::GetFrames() {
|
||||
}
|
||||
|
||||
already_AddRefed<nsPIDOMWindowOuter> nsGlobalWindowInner::IndexedGetter(
|
||||
JSContext* aCx, uint32_t aIndex) {
|
||||
FORWARD_TO_OUTER(IndexedGetterOuter, (aCx, aIndex), nullptr);
|
||||
uint32_t aIndex) {
|
||||
FORWARD_TO_OUTER(IndexedGetterOuter, (aIndex), nullptr);
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -2884,17 +2884,6 @@ void nsGlobalWindowInner::GetOwnPropertyNames(JSContext* aCx,
|
||||
nsContentUtils::GetSystemPrincipal();
|
||||
}
|
||||
|
||||
/* static */ bool nsGlobalWindowInner::AllowChromeFrameAccess(JSContext* aCx,
|
||||
JSObject* aObj) {
|
||||
if (StaticPrefs::dom_chrome_frame_access_enabled() ||
|
||||
!nsContentUtils::IsSystemCaller(aCx)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return nsContentUtils::ObjectPrincipal(aObj) ==
|
||||
nsContentUtils::GetSystemPrincipal();
|
||||
}
|
||||
|
||||
/* static */ bool nsGlobalWindowInner::OfflineCacheAllowedForContext(
|
||||
JSContext* aCx, JSObject* aObj) {
|
||||
return IsSecureContextOrObjectIsFromSecureContext(aCx, aObj) ||
|
||||
@ -3315,9 +3304,7 @@ double nsGlobalWindowInner::GetScrollY(ErrorResult& aError) {
|
||||
FORWARD_TO_OUTER_OR_THROW(GetScrollYOuter, (), aError, 0);
|
||||
}
|
||||
|
||||
uint32_t nsGlobalWindowInner::Length(mozilla::dom::CallerType aCallerType) {
|
||||
FORWARD_TO_OUTER(Length, (aCallerType), 0);
|
||||
}
|
||||
uint32_t nsGlobalWindowInner::Length() { FORWARD_TO_OUTER(Length, (), 0); }
|
||||
|
||||
already_AddRefed<nsPIDOMWindowOuter> nsGlobalWindowInner::GetTop(
|
||||
mozilla::ErrorResult& aError) {
|
||||
|
@ -387,20 +387,10 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
// WebIDL interface.
|
||||
already_AddRefed<nsPIDOMWindowOuter> IndexedGetter(JSContext* aCx,
|
||||
uint32_t aIndex);
|
||||
already_AddRefed<nsPIDOMWindowOuter> IndexedGetter(uint32_t aIndex);
|
||||
|
||||
static bool IsPrivilegedChromeWindow(JSContext* /* unused */, JSObject* aObj);
|
||||
|
||||
// The pref dom.chrome_frame_access.enabled can be used to block
|
||||
// various methods that chrome code can be used to traverse
|
||||
// content subframes. This is useful to enforce Fission-compatible
|
||||
// behavior on code. The current methods blocked are:
|
||||
// iframe.contentWindow, iframe.contentDocument, window.top,
|
||||
// window.opener, window.parent, window.frames[i], window.frames.length,
|
||||
// MessageEvent.source.
|
||||
static bool AllowChromeFrameAccess(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
static bool OfflineCacheAllowedForContext(JSContext* /* unused */,
|
||||
JSObject* aObj);
|
||||
|
||||
@ -632,7 +622,7 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
||||
void Blur(mozilla::ErrorResult& aError);
|
||||
nsDOMWindowList* GetFrames() final;
|
||||
already_AddRefed<nsPIDOMWindowOuter> GetFrames(mozilla::ErrorResult& aError);
|
||||
uint32_t Length(mozilla::dom::CallerType aCallerType);
|
||||
uint32_t Length();
|
||||
already_AddRefed<nsPIDOMWindowOuter> GetTop(mozilla::ErrorResult& aError);
|
||||
|
||||
protected:
|
||||
|
@ -779,14 +779,12 @@ already_AddRefed<nsPIDOMWindowOuter> nsOuterWindowProxy::GetSubframeWindow(
|
||||
}
|
||||
|
||||
nsGlobalWindowOuter* win = GetOuterWindow(proxy);
|
||||
return win->IndexedGetterOuter(cx, index);
|
||||
return win->IndexedGetterOuter(index);
|
||||
}
|
||||
|
||||
bool nsOuterWindowProxy::AppendIndexedPropertyNames(
|
||||
JSContext* cx, JSObject* proxy, JS::AutoIdVector& props) const {
|
||||
uint32_t length = GetOuterWindow(proxy)->Length(
|
||||
nsContentUtils::IsSystemCaller(cx) ? CallerType::System
|
||||
: CallerType::NonSystem);
|
||||
uint32_t length = GetOuterWindow(proxy)->Length();
|
||||
MOZ_ASSERT(int32_t(length) >= 0);
|
||||
if (!props.reserve(props.length() + length)) {
|
||||
return false;
|
||||
@ -2839,22 +2837,11 @@ nsDOMWindowList* nsGlobalWindowOuter::GetFrames() {
|
||||
}
|
||||
|
||||
already_AddRefed<nsPIDOMWindowOuter> nsGlobalWindowOuter::IndexedGetterOuter(
|
||||
JSContext* aCx, uint32_t aIndex) {
|
||||
uint32_t aIndex) {
|
||||
nsDOMWindowList* windows = GetFrames();
|
||||
NS_ENSURE_TRUE(windows, nullptr);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> win = windows->IndexedGetter(aIndex);
|
||||
|
||||
if (win && !StaticPrefs::dom_chrome_frame_access_enabled()) {
|
||||
nsGlobalWindowOuter* global = nsGlobalWindowOuter::Cast(win);
|
||||
|
||||
if (!nsGlobalWindowInner::AllowChromeFrameAccess(
|
||||
aCx, global->GetGlobalJSObject())) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return win.forget();
|
||||
return windows->IndexedGetter(aIndex);
|
||||
}
|
||||
|
||||
nsIControllers* nsGlobalWindowOuter::GetControllersOuter(ErrorResult& aError) {
|
||||
@ -3557,12 +3544,7 @@ double nsGlobalWindowOuter::GetScrollXOuter() { return GetScrollXY(false).x; }
|
||||
|
||||
double nsGlobalWindowOuter::GetScrollYOuter() { return GetScrollXY(false).y; }
|
||||
|
||||
uint32_t nsGlobalWindowOuter::Length(mozilla::dom::CallerType aCallerType) {
|
||||
if (!StaticPrefs::dom_chrome_frame_access_enabled() &&
|
||||
aCallerType == CallerType::System) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t nsGlobalWindowOuter::Length() {
|
||||
nsDOMWindowList* windows = GetFrames();
|
||||
|
||||
return windows ? windows->GetLength() : 0;
|
||||
|
@ -354,8 +354,7 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
|
||||
// nsIObserver
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
already_AddRefed<nsPIDOMWindowOuter> IndexedGetterOuter(JSContext* aCx,
|
||||
uint32_t aIndex);
|
||||
already_AddRefed<nsPIDOMWindowOuter> IndexedGetterOuter(uint32_t aIndex);
|
||||
|
||||
already_AddRefed<nsPIDOMWindowOuter> GetTop() override;
|
||||
nsPIDOMWindowOuter* GetScriptableTop() override;
|
||||
@ -529,7 +528,7 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
|
||||
void BlurOuter();
|
||||
already_AddRefed<nsPIDOMWindowOuter> GetFramesOuter();
|
||||
nsDOMWindowList* GetFrames() final;
|
||||
uint32_t Length(mozilla::dom::CallerType aCallerType);
|
||||
uint32_t Length();
|
||||
already_AddRefed<nsPIDOMWindowOuter> GetTopOuter();
|
||||
|
||||
nsresult GetPrompter(nsIPrompt** aPrompt) override;
|
||||
|
@ -18,8 +18,6 @@ support-files =
|
||||
test_largeAllocationFormSubmit.sjs
|
||||
helper_largeAllocation.js
|
||||
helper_localStorage_e10s.js
|
||||
test_dom_chromeframes_top.html
|
||||
test_dom_chromeframes_inner.html
|
||||
!/dom/tests/mochitest/geolocation/network_geolocation.sjs
|
||||
|
||||
[browser_allocateGigabyte.js]
|
||||
@ -46,7 +44,6 @@ support-files =
|
||||
skip-if = e10s
|
||||
[browser_ConsoleStorageAPITests.js]
|
||||
[browser_ConsoleStoragePBTest_perwindowpb.js]
|
||||
[browser_dom_chrome_frame_access.js]
|
||||
[browser_focus_steal_from_chrome.js]
|
||||
[browser_focus_steal_from_chrome_during_mousedown.js]
|
||||
[browser_frame_elements.js]
|
||||
|
@ -1,52 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const TEST_URI = "http://example.com/browser/dom/tests/browser/test_dom_chromeframes_top.html";
|
||||
|
||||
add_task(async function() {
|
||||
SpecialPowers.pushPrefEnv({set: [["dom.chrome_frame_access.enabled", true]]})
|
||||
await testProperties(TEST_URI, true);
|
||||
|
||||
SpecialPowers.pushPrefEnv({set: [["dom.chrome_frame_access.enabled", false]]})
|
||||
await testProperties(TEST_URI, false);
|
||||
});
|
||||
|
||||
async function testProperties(uri, shouldBeDefined) {
|
||||
await BrowserTestUtils.withNewTab(uri, async function(browser) {
|
||||
// eslint-disable-next-line no-shadow
|
||||
await ContentTask.spawn(browser, shouldBeDefined, async function (shouldBeDefined) {
|
||||
let iframe = content.document.querySelector("iframe");
|
||||
let rawIframe = ChromeUtils.waiveXrays(iframe);
|
||||
|
||||
ok(rawIframe.contentWindow, "Not null");
|
||||
|
||||
let messageEvent = await new Promise(resolve => {
|
||||
content.addEventListener("message",
|
||||
messageEvent => resolve(messageEvent),
|
||||
{once: true});
|
||||
rawIframe.contentWindow.postMessage("syn", "*");
|
||||
});
|
||||
|
||||
ok(messageEvent, "message received");
|
||||
is(messageEvent.data, "ack", "ack received");
|
||||
|
||||
let innerWindow = ChromeUtils.unwaiveXrays(rawIframe.contentWindow);
|
||||
|
||||
is(content.frames.length > 0, shouldBeDefined, "Window.frames.length");
|
||||
is(content.frames[0] !== undefined, shouldBeDefined, "Window.frames - IndexedGetter");
|
||||
|
||||
// Ignored test case:
|
||||
// - privileged -> unprivileged named getter is blocked by default.
|
||||
// is(content.frames["testframe"] !== undefined, shouldBeDefined, "Window.frames - Named Getter");
|
||||
|
||||
is(iframe.contentWindow !== undefined, shouldBeDefined, "HTMLIframeElement.contentWindow");
|
||||
is(iframe.contentDocument !== undefined, shouldBeDefined, "HTMLIframeElement.contentDocument");
|
||||
|
||||
is(innerWindow.parent !== undefined, shouldBeDefined, "Window.parent");
|
||||
is(innerWindow.top !== undefined, shouldBeDefined, "Window.top");
|
||||
is(innerWindow.opener !== undefined, shouldBeDefined, "Window.opener");
|
||||
|
||||
is(messageEvent.source !== undefined, shouldBeDefined, "MessageEvent.source");
|
||||
});
|
||||
});
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test dom.strictChromeFrameAccess.enabled pref inner frame</title>
|
||||
</head>
|
||||
<script>
|
||||
addEventListener("message", function(e) {
|
||||
if (e.data == "syn") {
|
||||
window.parent.postMessage("ack", "*");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<body>
|
||||
<p>inner frame</p>
|
||||
</body>
|
||||
</html>
|
@ -1,10 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test dom.strictChromeFrameAccess.enabled pref</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Test dom.strictChromeFrameAccess.enabled pref</p>
|
||||
<iframe id="testframe" name="testframe" src="test_dom_chromeframes_inner.html"></iframe>
|
||||
</body>
|
||||
</html>
|
@ -33,9 +33,8 @@ interface HTMLIFrameElement : HTMLElement {
|
||||
attribute DOMString height;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute DOMString referrerPolicy;
|
||||
[NeedsSubjectPrincipal, Func="nsGlobalWindowInner::AllowChromeFrameAccess"]
|
||||
[NeedsSubjectPrincipal]
|
||||
readonly attribute Document? contentDocument;
|
||||
[Func="nsGlobalWindowInner::AllowChromeFrameAccess"]
|
||||
readonly attribute WindowProxy? contentWindow;
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,6 @@ interface MessageEvent : Event {
|
||||
/**
|
||||
* The window or port which originated this event.
|
||||
*/
|
||||
[Func="nsGlobalWindowInner::AllowChromeFrameAccess"]
|
||||
readonly attribute MessageEventSource? source;
|
||||
|
||||
[Pure, Cached, Frozen]
|
||||
|
@ -55,15 +55,12 @@ typedef OfflineResourceList ApplicationCache;
|
||||
|
||||
// other browsing contexts
|
||||
[Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy frames;
|
||||
[Replaceable, CrossOriginReadable, NeedsCallerType] readonly attribute unsigned long length;
|
||||
[Replaceable, CrossOriginReadable] readonly attribute unsigned long length;
|
||||
//[Unforgeable, Throws, CrossOriginReadable] readonly attribute WindowProxy top;
|
||||
[Unforgeable, Throws, CrossOriginReadable, Func="nsGlobalWindowInner::AllowChromeFrameAccess"]
|
||||
readonly attribute WindowProxy? top;
|
||||
[Throws, CrossOriginReadable, Func="nsGlobalWindowInner::AllowChromeFrameAccess"]
|
||||
attribute any opener;
|
||||
[Unforgeable, Throws, CrossOriginReadable] readonly attribute WindowProxy? top;
|
||||
[Throws, CrossOriginReadable] attribute any opener;
|
||||
//[Throws] readonly attribute WindowProxy parent;
|
||||
[Replaceable, Throws, CrossOriginReadable, Func="nsGlobalWindowInner::AllowChromeFrameAccess"]
|
||||
readonly attribute WindowProxy? parent;
|
||||
[Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy? parent;
|
||||
[Throws, NeedsSubjectPrincipal] readonly attribute Element? frameElement;
|
||||
//[Throws] WindowProxy? open(optional USVString url = "about:blank", optional DOMString target = "_blank", [TreatNullAs=EmptyString] optional DOMString features = "");
|
||||
[Throws] WindowProxy? open(optional DOMString url = "", optional DOMString target = "", [TreatNullAs=EmptyString] optional DOMString features = "");
|
||||
|
@ -1638,7 +1638,7 @@ bool DOMXrayTraits::resolveOwnProperty(JSContext* cx, HandleObject wrapper,
|
||||
nsGlobalWindowInner* win = AsWindow(cx, wrapper);
|
||||
// Note: As() unwraps outer windows to get to the inner window.
|
||||
if (win) {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> subframe = win->IndexedGetter(cx, index);
|
||||
nsCOMPtr<nsPIDOMWindowOuter> subframe = win->IndexedGetter(index);
|
||||
if (subframe) {
|
||||
subframe->EnsureInnerWindow();
|
||||
nsGlobalWindowOuter* global = nsGlobalWindowOuter::Cast(subframe);
|
||||
@ -1707,9 +1707,7 @@ bool DOMXrayTraits::enumerateNames(JSContext* cx, HandleObject wrapper,
|
||||
// Put the indexed properties for a window first.
|
||||
nsGlobalWindowInner* win = AsWindow(cx, wrapper);
|
||||
if (win) {
|
||||
uint32_t length =
|
||||
win->Length(nsContentUtils::IsSystemCaller(cx) ? CallerType::System
|
||||
: CallerType::NonSystem);
|
||||
uint32_t length = win->Length();
|
||||
if (!props.reserve(props.length() + length)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -287,13 +287,6 @@ VARCACHE_PREF(
|
||||
RelaxedAtomicBool, false
|
||||
)
|
||||
|
||||
// Allow chrome code to access non-privileged frames.
|
||||
VARCACHE_PREF(
|
||||
"dom.chrome_frame_access.enabled",
|
||||
dom_chrome_frame_access_enabled,
|
||||
bool, true
|
||||
)
|
||||
|
||||
// Enable printing performance marks/measures to log
|
||||
VARCACHE_PREF(
|
||||
"dom.performance.enable_user_timing_logging",
|
||||
|
Loading…
x
Reference in New Issue
Block a user