Commit 890c4d9d authored by binji's avatar binji Committed by Commit bot

[d8 Workers] Throw when calling Worker constructor without new

BUG=4399
R=jarin@chromium.org
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#30016}
parent 53be2063
...@@ -699,6 +699,11 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -699,6 +699,11 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
return; return;
} }
if (!args.IsConstructCall()) {
Throw(args.GetIsolate(), "Worker must be constructed with new");
return;
}
{ {
base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer());
// Initialize the internal field to NULL; if we return early without // Initialize the internal field to NULL; if we return early without
......
// 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.
if (this.Worker) {
assertThrows(function() { Worker.prototype.constructor("55"); });
}
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