[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}
This commit is contained in:
binji 2015-08-04 13:39:10 -07:00 committed by Commit bot
parent 53be2063cc
commit 890c4d9dc6
2 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,8 @@
// 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"); });
}