v8/test/mjsunit/strong/load-super.js
conradw ea4e568363 [strong] Add tests for loading from proxy, super, with access checks
Followup for https://codereview.chromium.org/1168093002/

These seem to already function correctly without the need for further runtime
changes.

There will be a final follow-up for interceptors.

BUG=v8:3956
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#29389}
2015-06-30 17:13:21 +00:00

103 lines
1.6 KiB
JavaScript

// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --strong-mode
"use strong";
function testSuper(object) {
assertEquals(0, object.validLoad());
assertThrows(function(){ return object.propertyLoad() }, TypeError);
assertThrows(function(){ return object.elementLoad() }, TypeError);
assertThrows(function(){ return object.accessorLoad() }, TypeError);
}
class A {
constructor() {}
foo() {
return 0;
}
get bar() {
return 0;
}
set baz(_) {
return;
}
}
class B extends A {
constructor() {
super();
}
validLoad() {
return super.foo() + super.bar;
}
propertyLoad() {
return super.x;
}
elementLoad() {
return super[1];
}
accessorLoad() {
return super.baz;
}
}
class C extends A {
constructor() {
super();
this[1] = 0;
this.x = 0;
}
get baz() {
return 0;
}
validLoad() {
return super.foo() + super.bar;
}
propertyLoad() {
return super.x;
}
elementLoad() {
return super[1];
}
accessorLoad() {
return super.baz;
}
}
let b = new B();
let c = new C();
testSuper(b);
testSuper(c);
let d = {
"0": 0,
foo: 0,
bar: (function(){return 0}),
get baz(){return 0},
set qux(_){return}
}
let e = {
__proto__: d,
"1": 0,
x: 0,
get baz(){return 0},
validLoad() {
return super[0] + super.foo + super.bar() + super.baz;
},
propertyLoad() {
return super.x;
},
elementLoad() {
return super[1];
},
accessorLoad() {
return super.qux;
}
}
testSuper(e);