Reviewers: Jarin,

Description:
[d8 Workers] Throw when calling Worker constructor without new

BUG=4399
[email protected]
LOG=n

Please review this at https://codereview.chromium.org/1260813008/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+6, -2 lines):
  M src/d8.cc
  A + test/mjsunit/regress-4399.js


Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index ddef1def632d33b6454a4467a00bda3e8aefa7a4..d55faabe8bcc414624f485a9af2c432516185dd6 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -699,6 +699,11 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
     return;
   }

+  if (!args.IsConstructCall()) {
+    Throw(args.GetIsolate(), "Worker must be constructed with new");
+    return;
+  }
+
   {
     base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer());
     // Initialize the internal field to NULL; if we return early without
Index: test/mjsunit/regress-4399.js
diff --git a/test/mjsunit/regress/regress-crbug-503698.js b/test/mjsunit/regress-4399.js
similarity index 73%
copy from test/mjsunit/regress/regress-crbug-503698.js
copy to test/mjsunit/regress-4399.js
index 415d1bc81be5ac46fb358ce8ec681b1e5c276e07..a8fdab7d9d62dfa33d34987f8994536e5dc762cc 100644
--- a/test/mjsunit/regress/regress-crbug-503698.js
+++ b/test/mjsunit/regress-4399.js
@@ -2,8 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.

-// Flags: --invoke-weak-callbacks

 if (this.Worker) {
-  var __v_6 = new Worker('');
+  assertThrows(function() { Worker.prototype.constructor("55"); });
 }


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to