Commit 8e9c90ba authored by rossberg's avatar rossberg Committed by Commit bot

Make .prototype properties of Wasm constructors read-only

R=titzer@chromium.org
BUG=v8:5817

Review-Url: https://codereview.chromium.org/2620783005
Cr-Commit-Position: refs/heads/master@{#42184}
parent ede2fc1f
...@@ -566,8 +566,9 @@ void WebAssemblyMemoryGetBuffer( ...@@ -566,8 +566,9 @@ void WebAssemblyMemoryGetBuffer(
static i::Handle<i::FunctionTemplateInfo> NewTemplate(i::Isolate* i_isolate, static i::Handle<i::FunctionTemplateInfo> NewTemplate(i::Isolate* i_isolate,
FunctionCallback func) { FunctionCallback func) {
Isolate* isolate = reinterpret_cast<Isolate*>(i_isolate); Isolate* isolate = reinterpret_cast<Isolate*>(i_isolate);
Local<FunctionTemplate> local = FunctionTemplate::New(isolate, func); Local<FunctionTemplate> templ = FunctionTemplate::New(isolate, func);
return v8::Utils::OpenHandle(*local); templ->ReadOnlyPrototype();
return v8::Utils::OpenHandle(*templ);
} }
namespace internal { namespace internal {
......
...@@ -22,8 +22,6 @@ function assertErrorMessage(func, type, msg) { ...@@ -22,8 +22,6 @@ function assertErrorMessage(func, type, msg) {
assertThrows(func, type); assertThrows(func, type);
} }
let PROP_FLAGS = false; // property flags are implemented correctly
let emptyModuleBinary = (() => { let emptyModuleBinary = (() => {
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
return new Int8Array(builder.toBuffer()); return new Int8Array(builder.toBuffer());
...@@ -130,9 +128,9 @@ assertEq(new Module(emptyModuleBinary.buffer) instanceof Module, true); ...@@ -130,9 +128,9 @@ assertEq(new Module(emptyModuleBinary.buffer) instanceof Module, true);
// 'WebAssembly.Module.prototype' data property // 'WebAssembly.Module.prototype' data property
let moduleProtoDesc = Object.getOwnPropertyDescriptor(Module, 'prototype'); let moduleProtoDesc = Object.getOwnPropertyDescriptor(Module, 'prototype');
assertEq(typeof moduleProtoDesc.value, "object"); assertEq(typeof moduleProtoDesc.value, "object");
if (PROP_FLAGS) assertEq(moduleProtoDesc.writable, false); assertEq(moduleProtoDesc.writable, false);
if (PROP_FLAGS) assertEq(moduleProtoDesc.enumerable, false); assertEq(moduleProtoDesc.enumerable, false);
if (PROP_FLAGS) assertEq(moduleProtoDesc.configurable, false); assertEq(moduleProtoDesc.configurable, false);
// 'WebAssembly.Module.prototype' object // 'WebAssembly.Module.prototype' object
let moduleProto = Module.prototype; let moduleProto = Module.prototype;
...@@ -234,9 +232,9 @@ assertErrorMessage(() => new Instance({}), TypeError, "first argument must be a ...@@ -234,9 +232,9 @@ assertErrorMessage(() => new Instance({}), TypeError, "first argument must be a
// 'WebAssembly.Instance.prototype' data property // 'WebAssembly.Instance.prototype' data property
let instanceProtoDesc = Object.getOwnPropertyDescriptor(Instance, 'prototype'); let instanceProtoDesc = Object.getOwnPropertyDescriptor(Instance, 'prototype');
assertEq(typeof instanceProtoDesc.value, "object"); assertEq(typeof instanceProtoDesc.value, "object");
if (PROP_FLAGS) assertEq(instanceProtoDesc.writable, false); assertEq(instanceProtoDesc.writable, false);
if (PROP_FLAGS) assertEq(instanceProtoDesc.enumerable, false); assertEq(instanceProtoDesc.enumerable, false);
if (PROP_FLAGS) assertEq(instanceProtoDesc.configurable, false); assertEq(instanceProtoDesc.configurable, false);
// 'WebAssembly.Instance.prototype' object // 'WebAssembly.Instance.prototype' object
let instanceProto = Instance.prototype; let instanceProto = Instance.prototype;
...@@ -291,9 +289,9 @@ assertEq(new Memory({initial:1.5}).buffer.byteLength, kPageSize); ...@@ -291,9 +289,9 @@ assertEq(new Memory({initial:1.5}).buffer.byteLength, kPageSize);
// 'WebAssembly.Memory.prototype' data property // 'WebAssembly.Memory.prototype' data property
let memoryProtoDesc = Object.getOwnPropertyDescriptor(Memory, 'prototype'); let memoryProtoDesc = Object.getOwnPropertyDescriptor(Memory, 'prototype');
assertEq(typeof memoryProtoDesc.value, "object"); assertEq(typeof memoryProtoDesc.value, "object");
if (PROP_FLAGS) assertEq(memoryProtoDesc.writable, false); assertEq(memoryProtoDesc.writable, false);
if (PROP_FLAGS) assertEq(memoryProtoDesc.enumerable, false); assertEq(memoryProtoDesc.enumerable, false);
if (PROP_FLAGS) assertEq(memoryProtoDesc.configurable, false); assertEq(memoryProtoDesc.configurable, false);
// 'WebAssembly.Memory.prototype' object // 'WebAssembly.Memory.prototype' object
let memoryProto = Memory.prototype; let memoryProto = Memory.prototype;
...@@ -383,9 +381,9 @@ assertEq(new Table({initial:1, maximum:1.5, element:"anyfunc"}) instanceof Table ...@@ -383,9 +381,9 @@ assertEq(new Table({initial:1, maximum:1.5, element:"anyfunc"}) instanceof Table
// 'WebAssembly.Table.prototype' data property // 'WebAssembly.Table.prototype' data property
let tableProtoDesc = Object.getOwnPropertyDescriptor(Table, 'prototype'); let tableProtoDesc = Object.getOwnPropertyDescriptor(Table, 'prototype');
assertEq(typeof tableProtoDesc.value, "object"); assertEq(typeof tableProtoDesc.value, "object");
if (PROP_FLAGS) assertEq(tableProtoDesc.writable, false); assertEq(tableProtoDesc.writable, false);
if (PROP_FLAGS) assertEq(tableProtoDesc.enumerable, false); assertEq(tableProtoDesc.enumerable, false);
if (PROP_FLAGS) assertEq(tableProtoDesc.configurable, false); assertEq(tableProtoDesc.configurable, false);
// 'WebAssembly.Table.prototype' object // 'WebAssembly.Table.prototype' object
let tableProto = Table.prototype; let tableProto = Table.prototype;
......
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