Bug 946564 part 2. Make window._content chromeonly and define it in WebIDL. r=peterv

This commit is contained in:
Boris Zbarsky
2013-12-09 10:34:04 -05:00
parent 15ba3e1773
commit 00353248ce
10 changed files with 13 additions and 79 deletions

View File

@@ -583,7 +583,6 @@ bool nsDOMClassInfo::sIsInitialized = false;
jsid nsDOMClassInfo::sLocation_id = JSID_VOID;
jsid nsDOMClassInfo::sConstructor_id = JSID_VOID;
jsid nsDOMClassInfo::s_content_id = JSID_VOID;
jsid nsDOMClassInfo::sLength_id = JSID_VOID;
jsid nsDOMClassInfo::sItem_id = JSID_VOID;
jsid nsDOMClassInfo::sNamedItem_id = JSID_VOID;
@@ -716,7 +715,6 @@ nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
SET_JSID_TO_STRING(sLocation_id, cx, "location");
SET_JSID_TO_STRING(sConstructor_id, cx, "constructor");
SET_JSID_TO_STRING(s_content_id, cx, "_content");
SET_JSID_TO_STRING(sLength_id, cx, "length");
SET_JSID_TO_STRING(sItem_id, cx, "item");
SET_JSID_TO_STRING(sNamedItem_id, cx, "namedItem");
@@ -1965,7 +1963,6 @@ nsDOMClassInfo::ShutDown()
sLocation_id = JSID_VOID;
sConstructor_id = JSID_VOID;
s_content_id = JSID_VOID;
sLength_id = JSID_VOID;
sItem_id = JSID_VOID;
sEnumerate_id = JSID_VOID;
@@ -3256,21 +3253,6 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
return rv;
}
// Native code for window._content getter, this simply maps
// window._content to window.content for backwards compatibility only.
static bool
ContentWindowGetter(JSContext *cx, unsigned argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
if (!obj)
return false;
JS::Rooted<JS::Value> value(cx);
bool result = ::JS_GetProperty(cx, obj, "content", &value);
*vp = value;
return result;
}
template<class Interface>
static nsresult
LocationSetterGuts(JSContext *cx, JSObject *obj, JS::MutableHandle<JS::Value> vp)
@@ -3577,35 +3559,6 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
// NB: By accident, we previously didn't support this over Xrays. This is a
// deprecated non-standard feature, so there's no reason to start doing so
// now.
if ((s_content_id == id) && !xpc::WrapperFactory::IsXrayWrapper(obj)) {
// Map window._content to window.content for backwards
// compatibility, this should spit out an message on the JS
// console.
JS::Rooted<JSObject*> funObj(cx);
JSFunction *fun = ::JS_NewFunction(cx, ContentWindowGetter, 0, 0,
obj, "_content");
if (!fun) {
return NS_ERROR_OUT_OF_MEMORY;
}
funObj = ::JS_GetFunctionObject(fun);
if (!JS_WrapObject(cx, &funObj) ||
!JS_DefinePropertyById(cx, obj, id, JSVAL_VOID,
JS_DATA_TO_FUNC_PTR(JSPropertyOp, funObj.get()),
JS_StrictPropertyStub,
JSPROP_ENUMERATE | JSPROP_GETTER |
JSPROP_SHARED)) {
return NS_ERROR_FAILURE;
}
*objp = obj;
return NS_OK;
}
if (!(flags & JSRESOLVE_ASSIGNING) && sDocument_id == id) {
nsCOMPtr<nsIDocument> document = win->GetDoc();
JS::Rooted<JS::Value> v(cx);

View File

@@ -165,7 +165,6 @@ protected:
public:
static jsid sLocation_id;
static jsid sConstructor_id;
static jsid s_content_id;
static jsid sLength_id;
static jsid sItem_id;
static jsid sNamedItem_id;

View File

@@ -944,6 +944,10 @@ public:
const mozilla::dom::Sequence<JS::Value>& aExtraArgument,
mozilla::ErrorResult& aError);
JSObject* GetContent(JSContext* aCx, mozilla::ErrorResult& aError);
JSObject* Get_content(JSContext* aCx, mozilla::ErrorResult& aError)
{
return GetContent(aCx, aError);
}
protected:
// Array of idle observers that are notified of idle events.

View File

@@ -315,7 +315,7 @@ class IDLUnresolvedIdentifier(IDLObject):
assert len(name) > 0
if name[:2] == "__" and not allowDoubleUnderscore:
if name[:2] == "__" and name != "__content" and not allowDoubleUnderscore:
raise WebIDLError("Identifiers beginning with __ are reserved",
[location])
if name[0] == '_' and not allowDoubleUnderscore:

View File

@@ -10,7 +10,7 @@ interface nsIDOMElement;
interface nsIDOMEvent;
interface nsIMessageBroadcaster;
[scriptable, uuid(6ff5df67-22da-4379-bf57-da775dad19f8)]
[scriptable, uuid(0c10226f-8abb-4345-aa6b-2780a6f4687e)]
interface nsIDOMChromeWindow : nsISupports
{
const unsigned short STATE_MAXIMIZED = 1;

View File

@@ -6,6 +6,7 @@ support-files =
page_privatestorageevent.html
test-console-api.html
[browser_test__content.js]
[browser_ConsoleAPITests.js]
[browser_ConsoleStorageAPITests.js]
[browser_ConsoleStoragePBTest_perwindowpb.js]

View File

@@ -0,0 +1,4 @@
function test() {
is(window._content, window.content,
"_content needs to work, since extensions use it");
}

View File

@@ -13,7 +13,6 @@ support-files =
historyframes.html
[test_497898.html]
[test__content.html]
[test_bug504220.html]
[test_bug628069_1.html]
[test_bug628069_2.html]

View File

@@ -1,28 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=863390
-->
<head>
<title>Test for Bug 863390</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=863390">Mozilla Bug 863390</a>
<p id="display"></p>
<div id="content">
<iframe id="frame" style="height:100px; width:100px; border:0"></iframe>
<div id="status" style="display: none"></div>
</div>
<pre id="test">
<script type="application/javascript;version=1.7">
/** Test for Bug 863390 **/
is(window._content, window.content, "_content and content should be the same");
</script>
</body>
</html>

View File

@@ -336,6 +336,8 @@ partial interface Window {
any... extraArguments);
[Replaceable, Throws] readonly attribute object? content;
[ChromeOnly, Throws] readonly attribute object? __content;
};
Window implements TouchEventHandlers;