mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
90 lines
3.5 KiB
XML
90 lines
3.5 KiB
XML
<?xml version="1.0"?>
|
|
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
|
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=760109
|
|
-->
|
|
<window title="Mozilla Bug 760109"
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
|
|
|
<!-- 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=760109"
|
|
target="_blank">Mozilla Bug 760109</a>
|
|
</body>
|
|
|
|
<!-- test code goes here -->
|
|
<script type="application/javascript">
|
|
<![CDATA[
|
|
|
|
/** Test for COW prototype remapping.**/
|
|
|
|
// This gets decompiled and run inside the sandbox.
|
|
function sandboxCode() {
|
|
|
|
// Check that COWs for objects with standard prototypes use the standard
|
|
// prototype in the home compartment.
|
|
ok(Object.getPrototypeOf(chromeArray) === Array.prototype,
|
|
"Array prototype remapped properly");
|
|
var protoProto = Object.getPrototypeOf(Object.getPrototypeOf(chromeObject));
|
|
ok(protoProto === Object.prototype,
|
|
"Object prototype remapped properly");
|
|
|
|
// Check |constructor|. The semantics of this weird for the case of an
|
|
// object with a custom chrome-implemented prototype, because we'll end up
|
|
// bouncing up the prototype chain to Object, even though that's not fully
|
|
// accurate. It's unlikely to be a problem though, so we just verify that
|
|
// it does what we expect.
|
|
ok(chromeObject.constructor === Object, "Object constructor does what we expect");
|
|
ok(chromeArray.constructor === Array, "Array constructor remapped properly");
|
|
|
|
// We should be able to .forEach on the Array.
|
|
var concat = '';
|
|
chromeArray.forEach(function(val) { concat += val; });
|
|
is(concat, 'abz', "Should be able to .forEach COW-ed Array");
|
|
|
|
// Try other Array operations.
|
|
is(chromeArray.indexOf('b'), 1, "indexOf works correctly");
|
|
is(chromeArray.join(''), concat, "join works correctly");
|
|
is(chromeArray.slice(1).join(''), 'bz', "slice works correctly");
|
|
|
|
// Try some operations that modify the array.
|
|
is(chromeArray.pop(), 'z', "Able to call pop");
|
|
is(chromeArray.push('z'), 3, "Able to call push");
|
|
chromeArray.reverse();
|
|
is(chromeArray.join(''), 'zba', "Able to call reverse");
|
|
chromeArray.sort();
|
|
is(chromeArray.join(''), 'abz', "Able to call sort");
|
|
|
|
// We should be able to .hasOwnProperty on the Object, and have
|
|
// it filter the objects we can see.
|
|
ok(chromeObject.hasOwnProperty('foo'), "Should see r property");
|
|
ok(!chromeObject.hasOwnProperty('bar'), "Shouldn't see non-exposed property");
|
|
ok(chromeObject.hasOwnProperty('baz'), "Should see rw property");
|
|
}
|
|
|
|
// We use a constructor to create the test object so that there's an
|
|
// intermediate object on the prototype chain between the instance and the
|
|
// standard prototype.
|
|
function SomeConstructor() {
|
|
this.foo = 2;
|
|
this.bar = 3;
|
|
this.baz = 4;
|
|
this.__exposedProps__ = {foo: 'r', baz: 'rw'};
|
|
}
|
|
SomeConstructor.prototype.__exposedProps__ = {};
|
|
|
|
const Cu = Components.utils;
|
|
var sb = new Cu.Sandbox('http://www.example.org');
|
|
sb.chromeArray = ['a', 'b', 'z'];
|
|
sb.chromeArray.__exposedProps__ = {};
|
|
sb.chromeObject = new SomeConstructor();
|
|
sb.ok = ok;
|
|
sb.is = is;
|
|
Cu.evalInSandbox('(' + sandboxCode.toSource() + ')();', sb);
|
|
|
|
]]>
|
|
</script>
|
|
</window>
|