Bug 1016960 - make |instanceof WebIDLInterface| work with outer windows. r=bz.

--HG--
extra : rebase_source : d62525ea541af2cf832884fb8ea5398595887679
This commit is contained in:
Peter Van der Beken 2014-05-28 22:45:37 +02:00
parent 4c8d269435
commit 02271d1690
4 changed files with 36 additions and 4 deletions

View File

@ -1,6 +1,7 @@
[DEFAULT]
support-files =
file_url.jsm
file_empty.html
[test_bug715041.xul]
[test_bug715041_removal.xul]
@ -9,3 +10,4 @@ support-files =
[test_console.xul]
[test_navigator_resolve_identity_xrays.xul]
[test_sendQueryContentAndSelectionSetEvent.html]
[test_bug1016960.html]

View File

@ -0,0 +1,30 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1016960
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1016960</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/** Test for Bug 1016960 **/
var chromeWindow = window.open("chrome://mochitests/content/chrome/dom/base/test/file_empty.html", "1016960", "chrome");
ok(chromeWindow instanceof ChromeWindow, "A chrome window should return true for |instanceof ChromeWindow|.");
chromeWindow.close();
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1016960">Mozilla Bug 1016960</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>

View File

@ -1891,7 +1891,7 @@ InterfaceHasInstance(JSContext* cx, JS::Handle<JSObject*> obj,
const DOMIfaceAndProtoJSClass* clasp =
DOMIfaceAndProtoJSClass::FromJSClass(js::GetObjectClass(obj));
const DOMClass* domClass = GetDOMClass(js::UncheckedUnwrap(instance));
const DOMClass* domClass = GetDOMClass(js::UncheckedUnwrap(instance, /* stopAtOuter = */ false));
MOZ_ASSERT(!domClass || clasp->mPrototypeID != prototypes::id::_ID_Count,
"Why do we have a hasInstance hook if we don't have a prototype "

View File

@ -1735,7 +1735,7 @@ class CGClassHasInstanceHook(CGAbstractStaticMethod):
// FIXME Limit this to chrome by checking xpc::AccessCheck::isChrome(obj).
nsISupports* native =
nsContentUtils::XPConnect()->GetNativeOfWrapper(cx,
js::UncheckedUnwrap(instance));
js::UncheckedUnwrap(instance, /* stopAtOuter = */ false));
nsCOMPtr<nsIDOM${name}> qiResult = do_QueryInterface(native);
*bp = !!qiResult;
return true;
@ -1746,7 +1746,7 @@ class CGClassHasInstanceHook(CGAbstractStaticMethod):
hasInstanceCode = dedent("""
const DOMClass* domClass = GetDOMClass(js::UncheckedUnwrap(instance));
const DOMClass* domClass = GetDOMClass(js::UncheckedUnwrap(instance, /* stopAtOuter = */ false));
*bp = false;
if (!domClass) {
// Not a DOM object, so certainly not an instance of this interface
@ -1754,7 +1754,7 @@ class CGClassHasInstanceHook(CGAbstractStaticMethod):
}
""")
if self.descriptor.interface.identifier.name == "ChromeWindow":
setBp = "*bp = UnwrapDOMObject<nsGlobalWindow>(js::UncheckedUnwrap(instance))->IsChromeWindow()"
setBp = "*bp = UnwrapDOMObject<nsGlobalWindow>(js::UncheckedUnwrap(instance, /* stopAtOuter = */ false))->IsChromeWindow()"
else:
setBp = "*bp = true"
# Sort interaces implementing self by name so we get stable output.