Try to switch Array builtins into strict mode.

R=rossberg@chromium.org
TEST=mjsunit,test262,webkit

Review URL: https://codereview.chromium.org/233083003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20717 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent de50f63f
......@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"use strict";
// This file relies on the fact that the following declarations have been made
// in runtime.js:
// var $Array = global.Array;
......
......@@ -25,7 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"use strict";
// This file relies on the fact that the following declaration has been made
......
......@@ -46,10 +46,10 @@ f(null);
// Check called from eval.
eval('f(null)');
// Check called from builtin functions. Only show the initially called
// (publicly exposed) builtin function, not it's internal helper functions.
[Array.prototype.sort, Array.prototype.sort].sort(f);
// Check called from strict builtin functions.
[null, null].sort(f);
// Check called from sloppy builtin functions.
"abel".replace(/b/g, function h() {
assertEquals(String.prototype.replace, h.caller);
});
......@@ -322,13 +322,15 @@ Object.freeze(obj);
// sufficient.
assertTrue(Object.isSealed(obj));
assertDoesNotThrow(function() { obj.push(); });
assertDoesNotThrow(function() { obj.unshift(); });
assertDoesNotThrow(function() { obj.splice(0,0); });
// Verify that the length can't be written by builtins.
assertThrows(function() { obj.push(); }, TypeError);
assertThrows(function() { obj.unshift(); }, TypeError);
assertThrows(function() { obj.splice(0,0); }, TypeError);
assertTrue(Object.isFrozen(obj));
// Verify that an item can't be changed with splice.
assertThrows(function() { obj.splice(0,1,1); }, TypeError);
assertTrue(Object.isFrozen(obj));
// Verify that unshift() with no arguments will fail if it reifies from
// the prototype into the object.
......
......@@ -30,19 +30,19 @@
function testfn(f) { return [1].map(f)[0]; }
function foo() { return [].map.caller; }
assertEquals(null, testfn(foo));
assertThrows(function() { testfn(foo); } );
// Try to delete the caller property (to make sure that we can't get to the
// caller accessor on the prototype.
delete Array.prototype.map.caller;
assertEquals(null, testfn(foo));
assertThrows(function() { testfn(foo); } );
// Redo tests with arguments object.
function testarguments(f) { return [1].map(f)[0]; }
function bar() { return [].map.arguments; }
assertEquals(null, testfn(bar));
assertThrows(function() { testarguments(bar); } );
// Try to delete the arguments property (to make sure that we can't get to the
// caller accessor on the prototype.
delete Array.prototype.map.arguments;
assertEquals(null, testarguments(bar));
assertThrows(function() { testarguments(bar); } );
......@@ -27,10 +27,10 @@
var a = [5, 4, 3, 2, 1, 0];
Object.freeze(a);
a.sort();
assertThrows(function() { a.sort(); });
assertArrayEquals([5, 4, 3, 2, 1, 0], a);
var b = {0: 5, 1: 4, 2: 3, 3: 2, 4: 1, 5: 0, length: 6};
Object.freeze(b);
Array.prototype.sort.call(b);
assertThrows(function() { Array.prototype.sort.call(b); });
assertPropertiesEqual({0: 5, 1: 4, 2: 3, 3: 2, 4: 1, 5: 0, length: 6}, b);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment