Commit 6911943e authored by machenbach's avatar machenbach Committed by Commit bot

Revert of Revert of [es6] don't throw if argument is non-object (O.freeze,...

Revert of Revert of [es6] don't throw if argument is non-object (O.freeze, O.seal, O.preventExtensions) (patchset #1 id:1 of https://codereview.chromium.org/1103473003/)

Reason for revert:
This was probably an infrastructure problem caused by the mac ninja/goma switch.

Original issue's description:
> 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

TBR=arv@chromium.org,caitpotter88@gmail.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:3965, v8:3966

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

Cr-Commit-Position: refs/heads/master@{#27999}
parent 15b98a33
...@@ -1255,9 +1255,7 @@ function ProxyFix(obj) { ...@@ -1255,9 +1255,7 @@ function ProxyFix(obj) {
// ES5 section 15.2.3.8. // ES5 section 15.2.3.8.
function ObjectSealJS(obj) { function ObjectSealJS(obj) {
if (!IS_SPEC_OBJECT(obj)) { if (!IS_SPEC_OBJECT(obj)) return obj;
throw MakeTypeError(kCalledOnNonObject, "Object.seal");
}
var isProxy = %_IsJSProxy(obj); var isProxy = %_IsJSProxy(obj);
if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) { if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) {
if (isProxy) { if (isProxy) {
...@@ -1284,9 +1282,7 @@ function ObjectSealJS(obj) { ...@@ -1284,9 +1282,7 @@ function ObjectSealJS(obj) {
// ES5 section 15.2.3.9. // ES5 section 15.2.3.9.
function ObjectFreezeJS(obj) { function ObjectFreezeJS(obj) {
if (!IS_SPEC_OBJECT(obj)) { if (!IS_SPEC_OBJECT(obj)) return obj;
throw MakeTypeError(kCalledOnNonObject, "Object.freeze");
}
var isProxy = %_IsJSProxy(obj); var isProxy = %_IsJSProxy(obj);
if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) { if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) {
if (isProxy) { if (isProxy) {
...@@ -1314,9 +1310,7 @@ function ObjectFreezeJS(obj) { ...@@ -1314,9 +1310,7 @@ function ObjectFreezeJS(obj) {
// ES5 section 15.2.3.10 // ES5 section 15.2.3.10
function ObjectPreventExtension(obj) { function ObjectPreventExtension(obj) {
if (!IS_SPEC_OBJECT(obj)) { if (!IS_SPEC_OBJECT(obj)) return obj;
throw MakeTypeError(kCalledOnNonObject, "Object.preventExtension");
}
if (%_IsJSProxy(obj)) { if (%_IsJSProxy(obj)) {
ProxyFix(obj); ProxyFix(obj);
} }
...@@ -1327,9 +1321,7 @@ function ObjectPreventExtension(obj) { ...@@ -1327,9 +1321,7 @@ function ObjectPreventExtension(obj) {
// ES5 section 15.2.3.11 // ES5 section 15.2.3.11
function ObjectIsSealed(obj) { function ObjectIsSealed(obj) {
if (!IS_SPEC_OBJECT(obj)) { if (!IS_SPEC_OBJECT(obj)) return true;
throw MakeTypeError(kCalledOnNonObject, "Object.isSealed");
}
if (%_IsJSProxy(obj)) { if (%_IsJSProxy(obj)) {
return false; return false;
} }
...@@ -1350,9 +1342,7 @@ function ObjectIsSealed(obj) { ...@@ -1350,9 +1342,7 @@ function ObjectIsSealed(obj) {
// ES5 section 15.2.3.12 // ES5 section 15.2.3.12
function ObjectIsFrozen(obj) { function ObjectIsFrozen(obj) {
if (!IS_SPEC_OBJECT(obj)) { if (!IS_SPEC_OBJECT(obj)) return true;
throw MakeTypeError(kCalledOnNonObject, "Object.isFrozen");
}
if (%_IsJSProxy(obj)) { if (%_IsJSProxy(obj)) {
return false; return false;
} }
...@@ -1372,9 +1362,7 @@ function ObjectIsFrozen(obj) { ...@@ -1372,9 +1362,7 @@ function ObjectIsFrozen(obj) {
// ES5 section 15.2.3.13 // ES5 section 15.2.3.13
function ObjectIsExtensible(obj) { function ObjectIsExtensible(obj) {
if (!IS_SPEC_OBJECT(obj)) { if (!IS_SPEC_OBJECT(obj)) return false;
throw MakeTypeError(kCalledOnNonObject, "Object.isExtensible");
}
if (%_IsJSProxy(obj)) { if (%_IsJSProxy(obj)) {
return true; return true;
} }
......
...@@ -37,11 +37,6 @@ test(function() { ...@@ -37,11 +37,6 @@ test(function() {
[].forEach(1); [].forEach(1);
}, "1 is not a function", TypeError); }, "1 is not a function", TypeError);
// kCalledOnNonObject
test(function() {
Object.freeze(1)
}, "Object.freeze called on non-object", TypeError);
// kCannotConvertToPrimitive // kCannotConvertToPrimitive
test(function() { test(function() {
[].join(Object(Symbol(1))); [].join(Object(Symbol(1)));
......
...@@ -25,33 +25,20 @@ ...@@ -25,33 +25,20 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Tests the Object.freeze and Object.isFrozen methods - ES 15.2.3.9 and // Tests the Object.freeze and Object.isFrozen methods - ES 19.1.2.5 and
// ES 15.2.3.12 // ES 19.1.2.12
// Flags: --allow-natives-syntax // Flags: --allow-natives-syntax
// Test that we throw an error if an object is not passed as argument. // Test that we return obj if non-object is passed as argument
var non_objects = new Array(undefined, null, 1, -1, 0, 42.43); var non_objects = new Array(undefined, null, 1, -1, 0, 42.43, Symbol("test"));
for (var key in non_objects) { for (var key in non_objects) {
var exception = false; assertSame(non_objects[key], Object.freeze(non_objects[key]));
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) { for (var key in non_objects) {
exception = false; assertTrue(Object.isFrozen(non_objects[key]));
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. // Test normal data properties.
...@@ -348,3 +335,64 @@ assertFalse(Object.isFrozen(obj)); ...@@ -348,3 +335,64 @@ assertFalse(Object.isFrozen(obj));
Object.freeze(obj); Object.freeze(obj);
assertTrue(Object.isSealed(obj)); assertTrue(Object.isSealed(obj));
assertTrue(Object.isFrozen(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,33 +25,20 @@ ...@@ -25,33 +25,20 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Tests the Object.seal and Object.isSealed methods - ES 15.2.3.9 and // Tests the Object.seal and Object.isSealed methods - ES 19.1.2.17 and
// ES 15.2.3.12 // ES 19.1.2.13
// Flags: --allow-natives-syntax --noalways-opt // Flags: --allow-natives-syntax --noalways-opt
// Test that we throw an error if an object is not passed as argument. // Test that we return obj if non-object is passed as argument
var non_objects = new Array(undefined, null, 1, -1, 0, 42.43); var non_objects = new Array(undefined, null, 1, -1, 0, 42.43, Symbol("test"));
for (var key in non_objects) { for (var key in non_objects) {
var exception = false; assertSame(non_objects[key], Object.seal(non_objects[key]));
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) { for (var key in non_objects) {
exception = false; assertTrue(Object.isSealed(non_objects[key]));
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. // Test normal data properties.
...@@ -396,3 +383,9 @@ assertTrue(%HasFastProperties(obj)); ...@@ -396,3 +383,9 @@ assertTrue(%HasFastProperties(obj));
Object.seal(obj); Object.seal(obj);
assertTrue(%HasFastProperties(obj)); assertTrue(%HasFastProperties(obj));
assertTrue(Object.isSealed(obj)); assertTrue(Object.isSealed(obj));
function Sealed() {}
Object.seal(Sealed);
assertDoesNotThrow(function() { return new Sealed(); });
Sealed.prototype.prototypeExists = true;
assertTrue((new Sealed()).prototypeExists);
...@@ -260,36 +260,10 @@ ...@@ -260,36 +260,10 @@
'built-ins/Date/prototype/setFullYear/15.9.5.40_1': [FAIL], 'built-ins/Date/prototype/setFullYear/15.9.5.40_1': [FAIL],
'built-ins/Error/prototype/S15.11.4_A2': [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/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-212': [FAIL],
'built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-213': [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-214': [FAIL],
'built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-215': [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/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.1_T2': [FAIL],
'built-ins/Promise/prototype/then/S25.4.2.1_A3.2_T2': [FAIL], 'built-ins/Promise/prototype/then/S25.4.2.1_A3.2_T2': [FAIL],
......
...@@ -226,6 +226,36 @@ ...@@ -226,6 +226,36 @@
'15.3.4.5-21-4': [FAIL], '15.3.4.5-21-4': [FAIL],
'15.3.4.5-21-5': [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 ########################### ######################## NEEDS INVESTIGATION ###########################
# These test failures are specific to the intl402 suite and need investigation # These test failures are specific to the intl402 suite and need investigation
......
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