Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Unified Diff: test/mjsunit/es7/object-observe.js

Issue 265503002: Re-enable Object.observe and add enforcement for security invariants. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: cr comment Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-object-observe.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es7/object-observe.js
diff --git a/test/mjsunit/es7/object-observe.js b/test/mjsunit/es7/object-observe.js
index 0aa3601d73bddd93769d38f256a7798363265c5d..8ec22bceba701c6841ff7657de9dacee2168201f 100644
--- a/test/mjsunit/es7/object-observe.js
+++ b/test/mjsunit/es7/object-observe.js
@@ -113,6 +113,8 @@ Object.defineProperty(changeRecordWithAccessor, 'name', {
// Object.observe
assertThrows(function() { Object.observe("non-object", observer.callback); },
TypeError);
+assertThrows(function() { Object.observe(this, observer.callback); },
+ TypeError);
assertThrows(function() { Object.observe(obj, nonFunction); }, TypeError);
assertThrows(function() { Object.observe(obj, frozenFunction); }, TypeError);
assertEquals(obj, Object.observe(obj, observer.callback, [1]));
@@ -127,6 +129,8 @@ assertEquals(obj, Object.observe(obj, observer.callback));
// Object.unobserve
assertThrows(function() { Object.unobserve(4, observer.callback); }, TypeError);
+assertThrows(function() { Object.unobserve(this, observer.callback); },
+ TypeError);
assertThrows(function() { Object.unobserve(obj, nonFunction); }, TypeError);
assertEquals(obj, Object.unobserve(obj, observer.callback));
@@ -135,6 +139,7 @@ assertEquals(obj, Object.unobserve(obj, observer.callback));
var notifier = Object.getNotifier(obj);
assertSame(notifier, Object.getNotifier(obj));
assertEquals(null, Object.getNotifier(Object.freeze({})));
+assertThrows(function() { Object.getNotifier(this) }, TypeError);
assertFalse(notifier.hasOwnProperty('notify'));
assertEquals([], Object.keys(notifier));
var notifyDesc = Object.getOwnPropertyDescriptor(notifier.__proto__, 'notify');
@@ -1074,6 +1079,8 @@ function TestObserveNonConfigurable(obj, prop, desc) {
Object.unobserve(obj, observer.callback);
}
+// TODO(rafaelw) Enable when ES6 Proxies are implemented
+/*
function createProxy(create, x) {
var handler = {
getPropertyDescriptor: function(k) {
@@ -1113,11 +1120,11 @@ function createProxy(create, x) {
Object.observe(handler.target, handler.callback);
return handler.proxy = create(handler, x);
}
+*/
var objects = [
{},
[],
- this, // global object
function(){},
(function(){ return arguments })(),
(function(){ "use strict"; return arguments })(),
@@ -1125,9 +1132,10 @@ var objects = [
new Date(),
Object, Function, Date, RegExp,
new Set, new Map, new WeakMap,
- new ArrayBuffer(10), new Int32Array(5),
- createProxy(Proxy.create, null),
- createProxy(Proxy.createFunction, function(){}),
+ new ArrayBuffer(10), new Int32Array(5)
+// TODO(rafaelw) Enable when ES6 Proxies are implemented.
+// createProxy(Proxy.create, null),
+// createProxy(Proxy.createFunction, function(){}),
];
var properties = ["a", "1", 1, "length", "setPrototype", "name", "caller"];
« no previous file with comments | « test/cctest/test-object-observe.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698