зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1108930 - Part 7: Warn when Map/Set/WeakMap are called without new. r=evilpie
This commit is contained in:
Родитель
80ed789950
Коммит
103cb3319e
|
@ -1226,6 +1226,11 @@ MapObject::construct(JSContext *cx, unsigned argc, Value *vp)
|
|||
return false;
|
||||
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
// FIXME: bug 1083752
|
||||
if (!WarnIfNotConstructing(cx, args, "Map"))
|
||||
return false;
|
||||
|
||||
if (!args.get(0).isNullOrUndefined()) {
|
||||
RootedValue adderVal(cx);
|
||||
if (!GetProperty(cx, obj, obj, cx->names().set, &adderVal))
|
||||
|
@ -1870,6 +1875,11 @@ SetObject::construct(JSContext *cx, unsigned argc, Value *vp)
|
|||
return false;
|
||||
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
// FIXME: bug 1083752
|
||||
if (!WarnIfNotConstructing(cx, args, "Set"))
|
||||
return false;
|
||||
|
||||
if (!args.get(0).isNullOrUndefined()) {
|
||||
RootedValue adderVal(cx);
|
||||
if (!GetProperty(cx, obj, obj, cx->names().add, &adderVal))
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
// The Map constructor creates an empty Map by default.
|
||||
|
||||
load(libdir + "asserts.js");
|
||||
|
||||
var m = new Map();
|
||||
assertEq(m.size, 0);
|
||||
m = new Map(undefined);
|
||||
assertEq(m.size, 0);
|
||||
m = new Map(null);
|
||||
assertEq(m.size, 0);
|
||||
|
||||
// FIXME: bug 1083752
|
||||
options("werror");
|
||||
assertEq(evaluate("Map()", {catchTermination: true}), "terminated");
|
||||
// assertThrowsInstanceOf(() => Map(), TypeError);
|
||||
// assertThrowsInstanceOf(() => Map(undefined), TypeError);
|
||||
// assertThrowsInstanceOf(() => Map(null), TypeError);
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
// The Set constructor creates an empty Set by default.
|
||||
|
||||
load(libdir + "asserts.js");
|
||||
|
||||
var s = new Set();
|
||||
assertEq(s.size, 0);
|
||||
s = new Set(undefined);
|
||||
assertEq(s.size, 0);
|
||||
s = new Set(null);
|
||||
assertEq(s.size, 0);
|
||||
|
||||
// FIXME: bug 1083752
|
||||
options("werror");
|
||||
assertEq(evaluate("Set()", {catchTermination: true}), "terminated");
|
||||
// assertThrowsInstanceOf(() => Set(), TypeError);
|
||||
// assertThrowsInstanceOf(() => Set(undefined), TypeError);
|
||||
// assertThrowsInstanceOf(() => Set(null), TypeError);
|
||||
|
|
|
@ -6,7 +6,9 @@ new WeakMap();
|
|||
new WeakMap(undefined);
|
||||
new WeakMap(null);
|
||||
|
||||
// FIXME: bug 1062075
|
||||
// FIXME: bug 1083752
|
||||
options("werror");
|
||||
assertEq(evaluate("WeakMap()", {catchTermination: true}), "terminated");
|
||||
// assertThrowsInstanceOf(() => WeakMap(), TypeError);
|
||||
// assertThrowsInstanceOf(() => WeakMap(undefined), TypeError);
|
||||
// assertThrowsInstanceOf(() => WeakMap(null), TypeError);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "jsobjinlines.h"
|
||||
|
||||
#include "vm/Interpreter-inl.h"
|
||||
#include "vm/NativeObject-inl.h"
|
||||
|
||||
using namespace js;
|
||||
using namespace js::gc;
|
||||
|
@ -526,7 +527,12 @@ WeakMap_construct(JSContext *cx, unsigned argc, Value *vp)
|
|||
if (!obj)
|
||||
return false;
|
||||
|
||||
// ES6 23.3.1.1 steps 5-6, 11.
|
||||
// ES6 draft rev 31 (15 Jan 2015) 23.3.1.1 step 1.
|
||||
// FIXME: bug 1083752
|
||||
if (!WarnIfNotConstructing(cx, args, "WeakMap"))
|
||||
return false;
|
||||
|
||||
// Steps 5-6, 11.
|
||||
if (!args.get(0).isNullOrUndefined()) {
|
||||
// Steps 7a-b.
|
||||
RootedValue adderVal(cx);
|
||||
|
|
Загрузка…
Ссылка в новой задаче