Bug 580128. Make tests that now need to be chrome tests be chrome tests. r=jst@mozilla.org

--HG--
rename : js/src/xpconnect/tests/mochitest/test_bug484459.html => js/src/xpconnect/tests/chrome/test_bug484459.xul
rename : js/src/xpconnect/tests/mochitest/test_cows.html => js/src/xpconnect/tests/chrome/test_cows.xul
rename : js/src/xpconnect/tests/mochitest/test_wrappers.html => js/src/xpconnect/tests/chrome/test_wrappers-2.xul
This commit is contained in:
Mounir Lamouri 2010-09-30 00:14:30 -07:00
parent c3afb44113
commit e2809794f9
8 changed files with 165 additions and 126 deletions

View File

@ -52,6 +52,10 @@ _CHROME_FILES = \
test_evalInSandbox.xul \
test_sandboxImport.xul \
test_wrappers.xul \
test_wrappers-2.xul \
test_bug484459.xul \
file_wrappers-2.html \
test_cows.xul \
$(NULL)
libs:: $(_CHROME_FILES)

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<body>
<script>
var obj = {a: 3, next: 1};
var to_iterate = Object.create(obj);
var enumerate = { 0: 0, "hi": "there" };
function func () {};
var o = {};
var a = [1];
</script>
</body>
</html>

View File

@ -0,0 +1,37 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=484459
-->
<window title="Mozilla Bug 484459"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<iframe type="content"
src="data:text/html,&lt;script&gt;var x=3&lt;/script&gt;"
onload="go()"
id="ifr">
</iframe>
</body>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
SimpleTest.waitForExplicitFinish();
function go() {
var w = $('ifr').contentWindow.wrappedJSObject;
var sandbox = new Components.utils.Sandbox(w);
sandbox.__proto__ = w;
is(Components.utils.evalInSandbox("x * 4", sandbox), 12,
"Unexpected return from the sandbox");
SimpleTest.finish();
}
]]></script>
</window>

View File

@ -1,20 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for ChromeObjectWrappers</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=500931
-->
<window title="Mozilla Bug 522764"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=522764 "
target="_blank">Mozilla Bug 522764 </a>
</body>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
const Ci = Components.interfaces;
const Cu = Components.utils;
@ -24,8 +29,16 @@ var test_utils = window.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils);
function getCOW(x) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
return test_utils.getCOWForObject(x, x);
if (typeof x == "function")
return eval(uneval(x));
var rval = {};
for (var i in x) {
if (x.__lookupGetter__(i))
rval.__defineGetter__(i, eval(uneval(x.__lookupGetter__(i))))
else
rval[i] = x[i];
}
return rval;
}
// Give the sandbox a way to create ChromeObjectWrapped objects.
@ -201,8 +214,5 @@ try {
todo(false, "COWs should be unwrapped when entering chrome space, " +
"not raise " + e);
}
</script>
</pre>
</body>
</html>
]]></script>
</window>

View File

@ -1,12 +1,34 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Tests XPConnect Wrappers</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script class="testbody" type="text/javascript;version=1.7">
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=500931
-->
<window title="Mozilla Bug 500931"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=403005"
target="_blank">Mozilla Bug 403005</a>
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=409298"
target="_blank">Mozilla Bug 409298</a>
</body>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
/** Test for Bug 403005 and 409298 **/
SimpleTest.waitForExplicitFinish();
function go()
{
ok(window instanceof Object, "window is instanceof Object");
location.foopy = 3;
@ -59,60 +81,55 @@
for_each_expected.sort().toString(),
'wrapper iterators are properly iterators');
let wrap = $('ifr').contentWindow.wrappedJSObject;
let iwin = $('ifr').contentWindow;
let sjow_answer = [];
let (obj = { a: 3, next:1 }) {
for (let i in XPCSafeJSObjectWrapper({ __proto__: obj}))
for (let i in wrap.to_iterate)
sjow_answer.push(i);
is(sjow_answer.sort().toString(), ['a', 'next'].sort().toString(),
'enumeration over SJOWs walks the prototype chain');
}
sjow_answer = [];
for (let i in XPCSafeJSObjectWrapper(location))
for (let i in wrap.location)
sjow_answer.push(i);
is(sjow_answer.sort().toString(),
expected.sort().toString(),
'enumeration over SJOWs walks the prototype chain and works over XOWs');
for (let i in XPCSafeJSObjectWrapper({ 0: 0, "hi": "there" })) {
for (let i in wrap.enumerate) {
is(typeof i, "string", "enumeration on wrappers only returns strings");
}
ok(!(new XPCSafeJSObjectWrapper({}) == new XPCSafeJSObjectWrapper({})),
'SJOWs equality hook returns false correctly');
isnot(wrap, new XPCNativeWrapper(iwin),
'SJOWs equality hook returns false correctly against XPCNW');
let (obj = {}) {
ok(new XPCSafeJSObjectWrapper(obj) == new XPCSafeJSObjectWrapper(obj),
'SJOWs equality hook returns true correctly');
}
ok(new XPCSafeJSObjectWrapper(window) == new XPCNativeWrapper(window),
'SJOWs equality hook returns true correctly against XPCNW');
ok(new XPCSafeJSObjectWrapper(window) == window,
'SJOWs equality hook returns true correctly against XOW');
is(typeof(new XPCSafeJSObjectWrapper(function(){})), 'function',
is(typeof(wrap.func), 'function',
'SJOWs look like functions when they wrap functions');
is(typeof(new XPCSafeJSObjectWrapper({})), 'object',
is(typeof(wrap.o), 'object',
'SJOWs look like objects when they wrap objects');
ok(wrap.o === wrap.o,
"Identity holds when accessing the same object twice");
var origProto = window.__proto__;
var origProto = iwin.__proto__;
try {
window.__proto__ = window;
iwin.__proto__ = iwin;
ok(false, 'cyclic proto value allowed');
window.__proto__ = origProto;
iwin.__proto__ = origProto;
} catch (e) {
is(e.toString(),
'TypeError: cyclic __proto__ value',
'throw the right exception for a cyclic proto');
is(window.__proto__, origProto, 'reset __proto__ after a cyclic proto');
is(iwin.__proto__, origProto, 'reset __proto__ after a cyclic proto');
}
try {
is('PASS', window.eval("'PASS'"), 'window.eval throws an exception');
is('PASS', iwin.eval("'PASS'"), 'iwin.eval throws an exception');
} catch (e) {
ok(false, 'window.eval does not throw an exception');
ok(false, 'iwin.eval does not throw an exception');
}
try {
@ -129,58 +146,53 @@
}
// Some tests for SJOWs too.
is(new XPCSafeJSObjectWrapper(document.body) === document.body, true,
"triple equals ignores wrappers");
is(XPCSafeJSObjectWrapper.prototype + '',
"[object XPCSafeJSObjectWrapper]",
"able to convert XPCSafeJSObjectWrapper.prototype to string");
isnot(wrap.document.body != document.body, "body should not be the same");
XPCNativeWrapper.prototype = {};
let (w = new XPCNativeWrapper(window)) {
ok(window.location, "able to set XPCNativeWrapper.prototype and do stuff with it");
let (w = new XPCNativeWrapper(iwin)) {
ok(iwin.location, "able to set XPCNativeWrapper.prototype and do stuff with it");
}
is(new XPCNativeWrapper(window, Window).closed, false,
is(new XPCNativeWrapper(iwin, Window).closed, false,
"able to wrap a window in a window XPCNativeWrapper");
try {
new XPCNativeWrapper(document, Window);
ok(false, "Able to wrap a document in a Window XPCNativeWrapper?")
todo(false, "Able to wrap a document in a Window XPCNativeWrapper?")
} catch (e) {
ok(/ILLEGAL_VALUE/(e), "not able to wrap a document in a Window XPCNativeWrapper");
}
let (w = new XPCNativeWrapper(window)) {
let (w = new XPCNativeWrapper($('ifr').contentWindow)) {
w.foopybar = 5;
ok(!("foopybar" in window), "XPCNativeWrappers allow expandos through");
ok(!("foopybar" in iwin), "XPCNativeWrappers allow expandos through");
is(w.foopybar, 5, "can set expandos on XPCNativeWrappers, though");
ok(delete w.foopybar, "deleting properties returns true correctly");
ok(!("foopybar" in w), "Can delete properties from XPCNativeWrappers");
is(w.window, window, "w.window exists and is the window");
ok(delete w.window, "can delete builtin properties");
is(w.window, window, "w.window is automatically recreated");
is(w.window, iwin, "w.window exists and is the window");
ok(delete w.iwin, "can delete builtin properties");
is(w.window, iwin, "w.window is automatically recreated");
window.foopy = 5;
iwin.foopy = 5;
ok(delete w.foopy, "delete returns true");
is(window.foopy, 5, "delete doesn't delete underlying properties");
ok(delete window.foopy, "can delete window.foopy");
ok(!("foopy" in window), "foopy is no longer in window");
is(iwin.foopy, 5, "delete doesn't delete underlying properties");
ok(delete iwin.foopy, "can delete window.foopy");
ok(!("foopy" in iwin), "foopy is no longer in window");
}
try {
is((function(x) { return x+1; }).apply(this,
XPCSafeJSObjectWrapper([1])),
2, "able to call apply with an XPCSafeJSObjectWrapped array");
is((function(x) { return x+1; }).apply(this, wrap.a), 2,
"able to call apply with an XPCSafeJSObjectWrapped array");
} catch (e) {
ok(false,
"Unable to call apply() with a XPCSafeJSObjectWrapped array");
}
try {
window.__proto__ = null;
is(window.__proto__, null,
"allowed to update window.__proto__ to null");
iwin.__proto__ = null;
is(iwin.__proto__, null,
"allowed to update iwin.__proto__ to null");
} catch (e) {
ok(false, "some crazy exception was thrown");
}
@ -190,6 +202,13 @@
ok(false, "Allowed to wrap E4X in SJOWs?");
} catch (e) {
}
</script>
</body>
</html>
SimpleTest.finish();
}
]]></script>
<iframe type="content"
src="file_wrappers-2.html"
onload="go()"
id="ifr">
</iframe>
</window>

View File

@ -57,11 +57,9 @@ _TEST_FILES = bug500931_helper.html \
test_bug393269.html \
test_bug396851.html \
test_bug428021.html \
test_wrappers.html \
test_bug446584.html \
test_bug462428.html \
test_bug478438.html \
test_bug484459.html \
test_bug500691.html \
test_bug502959.html \
test_bug503926.html \
@ -71,7 +69,6 @@ _TEST_FILES = bug500931_helper.html \
test_bug553407.html \
test_bug560351.html \
test_bug564330.html \
test_cows.html \
test_frameWrapping.html \
test_bug589028.html \
bug589028_helper.html \

View File

@ -1,36 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=484459
-->
<head>
<title>Test for Bug 484459</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.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=484459">Mozilla Bug 484459</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 484459 **/
var x = 3;
var w = new XPCSafeJSObjectWrapper(window);
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var sandbox = new Components.utils.Sandbox(w);
sandbox.__proto__ = w;
is(Components.utils.evalInSandbox("x * 4", sandbox), 12,
"Unexpected return from the sandbox");
</script>
</pre>
</body>
</html>

View File

@ -39,11 +39,6 @@ function go() {
}
var xhr = new XMLHttpRequest();
/* XXX
var orsc = new XPCSafeJSObjectWrapper(function(){});
xhr.onreadystatechange = orsc;
// we only can test that the above didn't throw (which it shouldn't).
*/
try {
xhr.onreadystatechange = ifr.contentWindow;