| Index: test/mjsunit/regress/readonly4.js
|
| diff --git a/test/cctest/test-global-object.cc b/test/mjsunit/regress/readonly4.js
|
| similarity index 67%
|
| copy from test/cctest/test-global-object.cc
|
| copy to test/mjsunit/regress/readonly4.js
|
| index b124b2728dfe102fb9654c25ea0103e810c874f6..b2fde2953ba9bb4ae4cddc85c9479d157f02c41f 100644
|
| --- a/test/cctest/test-global-object.cc
|
| +++ b/test/mjsunit/regress/readonly4.js
|
| @@ -25,27 +25,50 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -#include "v8.h"
|
| -
|
| -#include "cctest.h"
|
| -
|
| -using namespace v8;
|
| -
|
| -// This test fails if properties on the prototype of the global object appear
|
| -// as declared globals.
|
| -TEST(StrictUndeclaredGlobalVariable) {
|
| - HandleScope scope(Isolate::GetCurrent());
|
| - v8::Local<v8::String> var_name = v8_str("x");
|
| - LocalContext context;
|
| - v8::TryCatch try_catch;
|
| - v8::Local<v8::Script> script = v8_compile("\"use strict\"; x = 42;");
|
| - v8::Handle<v8::Object> proto = v8::Object::New();
|
| - v8::Handle<v8::Object> global =
|
| - context->Global()->GetPrototype().As<v8::Object>();
|
| - proto->Set(var_name, v8_num(100));
|
| - global->SetPrototype(proto);
|
| - script->Run();
|
| - CHECK(try_catch.HasCaught());
|
| - v8::String::Utf8Value exception(try_catch.Exception());
|
| - CHECK_EQ("ReferenceError: x is not defined", *exception);
|
| +var slow = {};
|
| +var p = {};
|
| +
|
| +slow.__proto__ = p;
|
| +slow.x = 10;
|
| +slow.y = 10;
|
| +Object.defineProperty(p, "x", {writable:false, value:5});
|
| +
|
| +function c(p) {
|
| + return {__proto__: p};
|
| +}
|
| +
|
| +function s(v) {
|
| + return v.x = 1;
|
| +}
|
| +
|
| +function s_strict(v) {
|
| + "use strict";
|
| + v.x = 1;
|
| }
|
| +
|
| +var o1 = c(slow);
|
| +var o2 = c(slow);
|
| +var o1_strict = c(slow);
|
| +var o2_strict = c(slow);
|
| +var o3 = c(slow);
|
| +var o4 = c(slow);
|
| +
|
| +// Make s slow.
|
| +// Do this after using slow as prototype, since using an object as prototype
|
| +// kicks it back into fast mode.
|
| +delete slow.y;
|
| +
|
| +s(o1);
|
| +s(o2);
|
| +s_strict(o1_strict);
|
| +s_strict(o2_strict);
|
| +
|
| +delete slow.x;
|
| +// Directly setting x should fail.
|
| +o3.x = 20
|
| +assertEquals(5, o3.x);
|
| +
|
| +// Setting x through IC should fail.
|
| +s(o4);
|
| +assertEquals(5, o4.x);
|
| +assertThrows("s_strict(o4);", TypeError);
|
|
|