60 lines
1.5 KiB
HTML
60 lines
1.5 KiB
HTML
<p>
|
|
This page tests for correct behavior in the case of a prototype that transitions
|
|
to dictionary status. If the test passes, you'll see a series of PASS messages below.
|
|
</p>
|
|
|
|
<pre id="console"></pre>
|
|
|
|
<script>
|
|
(function() {
|
|
if (window.testRunner)
|
|
testRunner.dumpAsText();
|
|
|
|
function log(s)
|
|
{
|
|
if (this.document)
|
|
document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
|
|
else
|
|
print(s + "\n");
|
|
}
|
|
|
|
function shouldBe(a, aDescription, b)
|
|
{
|
|
if (a === b) {
|
|
log("PASS: " + aDescription + " should be " + b + " and is.");
|
|
} else {
|
|
log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
|
|
}
|
|
}
|
|
|
|
function getSlice(array)
|
|
{
|
|
return array.slice;
|
|
}
|
|
|
|
var array = [ ];
|
|
var slice = array.slice;
|
|
|
|
// Transition the array prototype to dictionary mode.
|
|
for (var i = 0; i < 256; ++i)
|
|
Array.prototype["p" + i] = 1;
|
|
|
|
// Try to cache access to an array prototype property (slice).
|
|
getSlice(array);
|
|
getSlice(array);
|
|
|
|
// Force the array prototype to rehash its storage.
|
|
for (var i = 256; i < 512; ++i)
|
|
Array.prototype["p" + i] = 1;
|
|
|
|
// Use previously cached access to slice.
|
|
shouldBe(slice === getSlice(array), "slice === getSlice(array)", true);
|
|
|
|
// Try to cache access to an array prototype property (slice).
|
|
getSlice(array);
|
|
getSlice(array);
|
|
|
|
shouldBe(slice === getSlice(array), "slice === getSlice(array)", true);
|
|
})();
|
|
</script>
|