Revert of [es6] don't throw if argument is non-object (O.freeze, O.seal, O.preventExtensions) (patchset #7 id:140001 of https://codereview.chromium.org/1011823003/)
Reason for revert: [Sheriff] breaks mac gc stress: http://build.chromium.org/p/client.v8/builders/V8%20Mac%20GC%20Stress/builds/1029 Original issue's description: > [es6] don't throw if argument is non-object (O.freeze, O.seal, O.preventExtensions) > > BUG=v8:3965, v8:3966 > R=arv@chromium.org > LOG=N > > Committed: https://crrev.com/b09c048f693d280052ac63c7d6b3baf27b3bf271 > Cr-Commit-Position: refs/heads/master@{#27985} TBR=arv@chromium.org,caitpotter88@gmail.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=v8:3965, v8:3966 Review URL: https://codereview.chromium.org/1103473003 Cr-Commit-Position: refs/heads/master@{#27990}
This commit is contained in:
parent
78f2efe0e4
commit
2b97a0e3bc
@ -1255,7 +1255,9 @@ function ProxyFix(obj) {
|
||||
|
||||
// ES5 section 15.2.3.8.
|
||||
function ObjectSealJS(obj) {
|
||||
if (!IS_SPEC_OBJECT(obj)) return obj;
|
||||
if (!IS_SPEC_OBJECT(obj)) {
|
||||
throw MakeTypeError(kCalledOnNonObject, "Object.seal");
|
||||
}
|
||||
var isProxy = %_IsJSProxy(obj);
|
||||
if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) {
|
||||
if (isProxy) {
|
||||
@ -1282,7 +1284,9 @@ function ObjectSealJS(obj) {
|
||||
|
||||
// ES5 section 15.2.3.9.
|
||||
function ObjectFreezeJS(obj) {
|
||||
if (!IS_SPEC_OBJECT(obj)) return obj;
|
||||
if (!IS_SPEC_OBJECT(obj)) {
|
||||
throw MakeTypeError(kCalledOnNonObject, "Object.freeze");
|
||||
}
|
||||
var isProxy = %_IsJSProxy(obj);
|
||||
if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) {
|
||||
if (isProxy) {
|
||||
@ -1310,7 +1314,9 @@ function ObjectFreezeJS(obj) {
|
||||
|
||||
// ES5 section 15.2.3.10
|
||||
function ObjectPreventExtension(obj) {
|
||||
if (!IS_SPEC_OBJECT(obj)) return obj;
|
||||
if (!IS_SPEC_OBJECT(obj)) {
|
||||
throw MakeTypeError(kCalledOnNonObject, "Object.preventExtension");
|
||||
}
|
||||
if (%_IsJSProxy(obj)) {
|
||||
ProxyFix(obj);
|
||||
}
|
||||
@ -1321,7 +1327,9 @@ function ObjectPreventExtension(obj) {
|
||||
|
||||
// ES5 section 15.2.3.11
|
||||
function ObjectIsSealed(obj) {
|
||||
if (!IS_SPEC_OBJECT(obj)) return true;
|
||||
if (!IS_SPEC_OBJECT(obj)) {
|
||||
throw MakeTypeError(kCalledOnNonObject, "Object.isSealed");
|
||||
}
|
||||
if (%_IsJSProxy(obj)) {
|
||||
return false;
|
||||
}
|
||||
@ -1342,7 +1350,9 @@ function ObjectIsSealed(obj) {
|
||||
|
||||
// ES5 section 15.2.3.12
|
||||
function ObjectIsFrozen(obj) {
|
||||
if (!IS_SPEC_OBJECT(obj)) return true;
|
||||
if (!IS_SPEC_OBJECT(obj)) {
|
||||
throw MakeTypeError(kCalledOnNonObject, "Object.isFrozen");
|
||||
}
|
||||
if (%_IsJSProxy(obj)) {
|
||||
return false;
|
||||
}
|
||||
@ -1362,7 +1372,9 @@ function ObjectIsFrozen(obj) {
|
||||
|
||||
// ES5 section 15.2.3.13
|
||||
function ObjectIsExtensible(obj) {
|
||||
if (!IS_SPEC_OBJECT(obj)) return false;
|
||||
if (!IS_SPEC_OBJECT(obj)) {
|
||||
throw MakeTypeError(kCalledOnNonObject, "Object.isExtensible");
|
||||
}
|
||||
if (%_IsJSProxy(obj)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -37,6 +37,11 @@ test(function() {
|
||||
[].forEach(1);
|
||||
}, "1 is not a function", TypeError);
|
||||
|
||||
// kCalledOnNonObject
|
||||
test(function() {
|
||||
Object.freeze(1)
|
||||
}, "Object.freeze called on non-object", TypeError);
|
||||
|
||||
// kCannotConvertToPrimitive
|
||||
test(function() {
|
||||
[].join(Object(Symbol(1)));
|
||||
|
@ -25,20 +25,33 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Tests the Object.freeze and Object.isFrozen methods - ES 19.1.2.5 and
|
||||
// ES 19.1.2.12
|
||||
// Tests the Object.freeze and Object.isFrozen methods - ES 15.2.3.9 and
|
||||
// ES 15.2.3.12
|
||||
|
||||
// Flags: --allow-natives-syntax
|
||||
|
||||
// Test that we return obj if non-object is passed as argument
|
||||
var non_objects = new Array(undefined, null, 1, -1, 0, 42.43, Symbol("test"));
|
||||
// Test that we throw an error if an object is not passed as argument.
|
||||
var non_objects = new Array(undefined, null, 1, -1, 0, 42.43);
|
||||
for (var key in non_objects) {
|
||||
assertSame(non_objects[key], Object.freeze(non_objects[key]));
|
||||
var exception = false;
|
||||
try {
|
||||
Object.freeze(non_objects[key]);
|
||||
} catch(e) {
|
||||
exception = true;
|
||||
assertTrue(/Object.freeze called on non-object/.test(e));
|
||||
}
|
||||
assertTrue(exception);
|
||||
}
|
||||
|
||||
// Test that isFrozen always returns true for non-objects
|
||||
for (var key in non_objects) {
|
||||
assertTrue(Object.isFrozen(non_objects[key]));
|
||||
exception = false;
|
||||
try {
|
||||
Object.isFrozen(non_objects[key]);
|
||||
} catch(e) {
|
||||
exception = true;
|
||||
assertTrue(/Object.isFrozen called on non-object/.test(e));
|
||||
}
|
||||
assertTrue(exception);
|
||||
}
|
||||
|
||||
// Test normal data properties.
|
||||
@ -335,64 +348,3 @@ assertFalse(Object.isFrozen(obj));
|
||||
Object.freeze(obj);
|
||||
assertTrue(Object.isSealed(obj));
|
||||
assertTrue(Object.isFrozen(obj));
|
||||
|
||||
|
||||
(function propertiesOfFrozenObjectNotFrozen() {
|
||||
function Frozen() {}
|
||||
Object.freeze(Frozen);
|
||||
assertDoesNotThrow(function() { return new Frozen(); });
|
||||
Frozen.prototype.prototypeExists = true;
|
||||
assertTrue((new Frozen()).prototypeExists);
|
||||
})();
|
||||
|
||||
|
||||
(function frozenPrototypePreventsPUT() {
|
||||
// A read-only property on the prototype should prevent a [[Put]] .
|
||||
function Constructor() {}
|
||||
Constructor.prototype.foo = 1;
|
||||
Object.freeze(Constructor.prototype);
|
||||
var obj = new Constructor();
|
||||
obj.foo = 2;
|
||||
assertSame(1, obj.foo);
|
||||
})();
|
||||
|
||||
|
||||
(function frozenFunctionSloppy() {
|
||||
// Check that freezing a function works correctly.
|
||||
var func = Object.freeze(function foo(){});
|
||||
assertTrue(Object.isFrozen(func));
|
||||
func.prototype = 42;
|
||||
assertFalse(func.prototype === 42);
|
||||
assertFalse(Object.getOwnPropertyDescriptor(func, "prototype").writable);
|
||||
})();
|
||||
|
||||
|
||||
(function frozenFunctionStrict() {
|
||||
// Check that freezing a strict function works correctly.
|
||||
var func = Object.freeze(function foo(){ "use strict"; });
|
||||
assertTrue(Object.isFrozen(func));
|
||||
func.prototype = 42;
|
||||
assertFalse(func.prototype === 42);
|
||||
assertFalse(Object.getOwnPropertyDescriptor(func, "prototype").writable);
|
||||
})();
|
||||
|
||||
|
||||
(function frozenArrayObject() {
|
||||
// Check that freezing array objects works correctly.
|
||||
var array = Object.freeze([0,1,2]);
|
||||
assertTrue(Object.isFrozen(array));
|
||||
array[0] = 3;
|
||||
assertEquals(0, array[0]);
|
||||
assertFalse(Object.getOwnPropertyDescriptor(array, "length").writable);
|
||||
})();
|
||||
|
||||
|
||||
(function frozenArgumentsObject() {
|
||||
// Check that freezing arguments objects works correctly.
|
||||
var args = Object.freeze((function(){ return arguments; })(0,1,2));
|
||||
assertTrue(Object.isFrozen(args));
|
||||
args[0] = 3;
|
||||
assertEquals(0, args[0]);
|
||||
assertFalse(Object.getOwnPropertyDescriptor(args, "length").writable);
|
||||
assertFalse(Object.getOwnPropertyDescriptor(args, "callee").writable);
|
||||
})();
|
||||
|
@ -25,20 +25,33 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Tests the Object.seal and Object.isSealed methods - ES 19.1.2.17 and
|
||||
// ES 19.1.2.13
|
||||
// Tests the Object.seal and Object.isSealed methods - ES 15.2.3.9 and
|
||||
// ES 15.2.3.12
|
||||
|
||||
// Flags: --allow-natives-syntax --noalways-opt
|
||||
|
||||
// Test that we return obj if non-object is passed as argument
|
||||
var non_objects = new Array(undefined, null, 1, -1, 0, 42.43, Symbol("test"));
|
||||
// Test that we throw an error if an object is not passed as argument.
|
||||
var non_objects = new Array(undefined, null, 1, -1, 0, 42.43);
|
||||
for (var key in non_objects) {
|
||||
assertSame(non_objects[key], Object.seal(non_objects[key]));
|
||||
var exception = false;
|
||||
try {
|
||||
Object.seal(non_objects[key]);
|
||||
} catch(e) {
|
||||
exception = true;
|
||||
assertTrue(/Object.seal called on non-object/.test(e));
|
||||
}
|
||||
assertTrue(exception);
|
||||
}
|
||||
|
||||
// Test that isFrozen always returns true for non-objects
|
||||
for (var key in non_objects) {
|
||||
assertTrue(Object.isSealed(non_objects[key]));
|
||||
exception = false;
|
||||
try {
|
||||
Object.isSealed(non_objects[key]);
|
||||
} catch(e) {
|
||||
exception = true;
|
||||
assertTrue(/Object.isSealed called on non-object/.test(e));
|
||||
}
|
||||
assertTrue(exception);
|
||||
}
|
||||
|
||||
// Test normal data properties.
|
||||
@ -383,9 +396,3 @@ assertTrue(%HasFastProperties(obj));
|
||||
Object.seal(obj);
|
||||
assertTrue(%HasFastProperties(obj));
|
||||
assertTrue(Object.isSealed(obj));
|
||||
|
||||
function Sealed() {}
|
||||
Object.seal(Sealed);
|
||||
assertDoesNotThrow(function() { return new Sealed(); });
|
||||
Sealed.prototype.prototypeExists = true;
|
||||
assertTrue((new Sealed()).prototypeExists);
|
||||
|
@ -260,10 +260,36 @@
|
||||
'built-ins/Date/prototype/setFullYear/15.9.5.40_1': [FAIL],
|
||||
'built-ins/Error/prototype/S15.11.4_A2': [FAIL],
|
||||
'built-ins/Object/defineProperty/15.2.3.6-4-293-4': [FAIL],
|
||||
'built-ins/Object/freeze/15.2.3.9-1': [FAIL],
|
||||
'built-ins/Object/freeze/15.2.3.9-1-1': [FAIL],
|
||||
'built-ins/Object/freeze/15.2.3.9-1-2': [FAIL],
|
||||
'built-ins/Object/freeze/15.2.3.9-1-3': [FAIL],
|
||||
'built-ins/Object/freeze/15.2.3.9-1-4': [FAIL],
|
||||
'built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-212': [FAIL],
|
||||
'built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-213': [FAIL],
|
||||
'built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-214': [FAIL],
|
||||
'built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-215': [FAIL],
|
||||
'built-ins/Object/isExtensible/15.2.3.13-1': [FAIL],
|
||||
'built-ins/Object/isExtensible/15.2.3.13-1-1': [FAIL],
|
||||
'built-ins/Object/isExtensible/15.2.3.13-1-2': [FAIL],
|
||||
'built-ins/Object/isExtensible/15.2.3.13-1-3': [FAIL],
|
||||
'built-ins/Object/isExtensible/15.2.3.13-1-4': [FAIL],
|
||||
'built-ins/Object/isFrozen/15.2.3.12-1': [FAIL],
|
||||
'built-ins/Object/isFrozen/15.2.3.12-1-1': [FAIL],
|
||||
'built-ins/Object/isFrozen/15.2.3.12-1-2': [FAIL],
|
||||
'built-ins/Object/isFrozen/15.2.3.12-1-3': [FAIL],
|
||||
'built-ins/Object/isFrozen/15.2.3.12-1-4': [FAIL],
|
||||
'built-ins/Object/isSealed/15.2.3.11-1': [FAIL],
|
||||
'built-ins/Object/preventExtensions/15.2.3.10-1': [FAIL],
|
||||
'built-ins/Object/preventExtensions/15.2.3.10-1-1': [FAIL],
|
||||
'built-ins/Object/preventExtensions/15.2.3.10-1-2': [FAIL],
|
||||
'built-ins/Object/preventExtensions/15.2.3.10-1-3': [FAIL],
|
||||
'built-ins/Object/preventExtensions/15.2.3.10-1-4': [FAIL],
|
||||
'built-ins/Object/seal/15.2.3.8-1': [FAIL],
|
||||
'built-ins/Object/seal/15.2.3.8-1-1': [FAIL],
|
||||
'built-ins/Object/seal/15.2.3.8-1-2': [FAIL],
|
||||
'built-ins/Object/seal/15.2.3.8-1-3': [FAIL],
|
||||
'built-ins/Object/seal/15.2.3.8-1-4': [FAIL],
|
||||
'built-ins/Promise/S25.4.3.1_A5.1_T2': [FAIL],
|
||||
'built-ins/Promise/prototype/then/S25.4.2.1_A3.1_T2': [FAIL],
|
||||
'built-ins/Promise/prototype/then/S25.4.2.1_A3.2_T2': [FAIL],
|
||||
|
@ -226,36 +226,6 @@
|
||||
'15.3.4.5-21-4': [FAIL],
|
||||
'15.3.4.5-21-5': [FAIL],
|
||||
|
||||
# Object.freeze(O), Object.seal(O), and Object.preventExtensions(O),
|
||||
# Object.isFrozen(O), Object.isSealed(O), and Object.isExtensible(O) no longer
|
||||
# throw when passed a non-object value in ES6.
|
||||
'15.2.3.8-1': [FAIL],
|
||||
'15.2.3.8-1-1': [FAIL],
|
||||
'15.2.3.8-1-2': [FAIL],
|
||||
'15.2.3.8-1-3': [FAIL],
|
||||
'15.2.3.8-1-4': [FAIL],
|
||||
'15.2.3.9-1': [FAIL],
|
||||
'15.2.3.9-1-1': [FAIL],
|
||||
'15.2.3.9-1-2': [FAIL],
|
||||
'15.2.3.9-1-3': [FAIL],
|
||||
'15.2.3.9-1-4': [FAIL],
|
||||
'15.2.3.10-1': [FAIL],
|
||||
'15.2.3.10-1-1': [FAIL],
|
||||
'15.2.3.10-1-2': [FAIL],
|
||||
'15.2.3.10-1-3': [FAIL],
|
||||
'15.2.3.10-1-4': [FAIL],
|
||||
'15.2.3.11-1': [FAIL],
|
||||
'15.2.3.12-1': [FAIL],
|
||||
'15.2.3.12-1-1': [FAIL],
|
||||
'15.2.3.12-1-2': [FAIL],
|
||||
'15.2.3.12-1-3': [FAIL],
|
||||
'15.2.3.12-1-4': [FAIL],
|
||||
'15.2.3.13-1': [FAIL],
|
||||
'15.2.3.13-1-1': [FAIL],
|
||||
'15.2.3.13-1-2': [FAIL],
|
||||
'15.2.3.13-1-3': [FAIL],
|
||||
'15.2.3.13-1-4': [FAIL],
|
||||
|
||||
######################## NEEDS INVESTIGATION ###########################
|
||||
|
||||
# These test failures are specific to the intl402 suite and need investigation
|
||||
|
Loading…
Reference in New Issue
Block a user