summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/WeakRef/prototype
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/WeakRef/prototype
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/WeakRef/prototype')
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/Symbol.toStringTag.js26
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/constructor.js34
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/deref/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/deref/custom-this.js30
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/deref/gc-cleanup-not-prevented-with-wr-deref.js38
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/deref/length.js35
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/deref/name.js34
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/deref/not-a-constructor.js36
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/deref/prop-desc.js27
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/deref/return-object-target.js28
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/deref/return-symbol-target.js29
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/deref/shell.js59
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-does-not-have-internal-target-throws.js53
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-not-object-throws.js55
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/proto.js17
-rw-r--r--js/src/tests/test262/built-ins/WeakRef/prototype/shell.js0
18 files changed, 522 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/Symbol.toStringTag.js b/js/src/tests/test262/built-ins/WeakRef/prototype/Symbol.toStringTag.js
new file mode 100644
index 0000000000..2dea339c1a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/Symbol.toStringTag.js
@@ -0,0 +1,26 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-weak-ref-@@tostringtag
+description: >
+ `Symbol.toStringTag` property descriptor
+info: |
+ The initial value of the @@toStringTag property is the String value
+ 'WeakRef'.
+
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]:
+ false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [WeakRef, Symbol, Symbol.toStringTag]
+---*/
+
+verifyProperty(WeakRef.prototype, Symbol.toStringTag, {
+ value: 'WeakRef',
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/browser.js b/js/src/tests/test262/built-ins/WeakRef/prototype/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/browser.js
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/constructor.js b/js/src/tests/test262/built-ins/WeakRef/prototype/constructor.js
new file mode 100644
index 0000000000..dd98eb40d8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/constructor.js
@@ -0,0 +1,34 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-properties-of-the-weak-ref-prototype-object
+description: WeakRef.prototype.constructor
+info: |
+ WeakRef.prototype.constructor
+
+ Normative Optional
+
+ The initial value of WeakRef.prototype.constructor is the intrinsic object %WeakRef%.
+
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
+
+ This section is to be treated identically to the "Annex B" of ECMA-262, but to be written in-line with the main specification.
+includes: [propertyHelper.js]
+features: [WeakRef]
+---*/
+
+var actual = WeakRef.prototype.hasOwnProperty('constructor');
+
+// If implemented, it should conform to the spec text
+if (actual) {
+ verifyProperty(WeakRef.prototype, 'constructor', {
+ value: WeakRef,
+ writable: true,
+ enumerable: false,
+ configurable: true
+ });
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/browser.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/browser.js
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/custom-this.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/custom-this.js
new file mode 100644
index 0000000000..923f153740
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/custom-this.js
@@ -0,0 +1,30 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-weak-ref.prototype.deref
+description: Return target if weakRef.[[Target]] is not empty (applying custom this)
+info: |
+ WeakRef.prototype.deref ()
+
+ 1. Let weakRef be the this value.
+ ...
+ 4. Let target be the value of weakRef.[[Target]].
+ 5. If target is not empty,
+ a. Perform ! KeepDuringJob(target).
+ b. Return target.
+ 6. Return undefined.
+features: [WeakRef]
+---*/
+
+var target = {};
+var deref = WeakRef.prototype.deref;
+var wref = new WeakRef(target);
+
+assert.sameValue(deref.call(wref), target, 'returns target');
+assert.sameValue(deref.call(wref), target, '[[Target]] is not emptied #1');
+assert.sameValue(deref.call(wref), target, '[[Target]] is not emptied #2');
+assert.sameValue(deref.call(wref), target, '[[Target]] is not emptied #3');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/gc-cleanup-not-prevented-with-wr-deref.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/gc-cleanup-not-prevented-with-wr-deref.js
new file mode 100644
index 0000000000..eacbad0129
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/gc-cleanup-not-prevented-with-wr-deref.js
@@ -0,0 +1,38 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) async -- WeakRef is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-weak-ref.prototype.deref
+description: WeakRef deref should not prevent a GC event
+info: |
+ WeakRef.prototype.deref ( )
+
+ ...
+ 4. Let target be the value of weakRef.[[Target]].
+ 5. If target is not empty,
+ a. Perform ! KeepDuringJob(target).
+ b. Return target.
+ 6. Return undefined.
+features: [FinalizationRegistry.prototype.cleanupSome, WeakRef, host-gc-required]
+includes: [async-gc.js]
+flags: [async, non-deterministic]
+---*/
+
+var deref = false;
+var wr;
+
+function emptyCells() {
+ var target = {};
+ wr = new WeakRef(target);
+
+ var prom = asyncGC(target);
+ target = null;
+
+ return prom;
+}
+
+emptyCells().then(function() {
+ deref = wr.deref();
+ assert.sameValue(deref, undefined);
+}).then($DONE, resolveAsyncGC);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/length.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/length.js
new file mode 100644
index 0000000000..33c9d3c46d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/length.js
@@ -0,0 +1,35 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-weak-ref.prototype.deref
+description: WeakRef.prototype.deref.length property descriptor
+info: |
+ WeakRef.prototype.deref ()
+
+ 17 ECMAScript Standard Built-in Objects
+
+ Every built-in function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description. Optional parameters
+ (which are indicated with brackets: [ ]) or rest parameters (which
+ are shown using the form «...name») are not included in the default
+ argument count.
+
+ Unless otherwise specified, the length property of a built-in
+ function object has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [WeakRef]
+---*/
+
+verifyProperty(WeakRef.prototype.deref, 'length', {
+ value: 0,
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/name.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/name.js
new file mode 100644
index 0000000000..04d100b0fc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/name.js
@@ -0,0 +1,34 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-weak-ref.prototype.deref
+description: WeakRef.prototype.deref.name property descriptor
+info: |
+ WeakRef.prototype.deref.name value and property descriptor
+
+ 17 ECMAScript Standard Built-in Objects
+
+ Every built-in function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String. Unless otherwise specified, this value is the name that
+ is given to the function in this specification. For functions that
+ are specified as properties of objects, the name value is the
+ property name string used to access the function. [...]
+
+ Unless otherwise specified, the name property of a built-in function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [WeakRef]
+---*/
+
+verifyProperty(WeakRef.prototype.deref, 'name', {
+ value: 'deref',
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/not-a-constructor.js
new file mode 100644
index 0000000000..9a97911843
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/not-a-constructor.js
@@ -0,0 +1,36 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ WeakRef.prototype.deref does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js]
+features: [Reflect.construct, WeakRef, arrow-function]
+---*/
+
+assert.sameValue(
+ isConstructor(WeakRef.prototype.deref),
+ false,
+ 'isConstructor(WeakRef.prototype.deref) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let wr = new WeakRef({}); new wr.deref();
+}, '`let wr = new WeakRef({}); new wr.deref()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/prop-desc.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/prop-desc.js
new file mode 100644
index 0000000000..6702c2ba71
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/prop-desc.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-weak-ref.prototype.deref
+description: >
+ Property descriptor of WeakRef.prototype.deref
+info: |
+ 17 ECMAScript Standard Built-in Objects:
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2
+ has the attributes { [[Writable]]: true, [[Enumerable]]: false,
+ [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+features: [WeakRef]
+---*/
+
+assert.sameValue(typeof WeakRef.prototype.deref, 'function');
+
+verifyProperty(WeakRef.prototype, 'deref', {
+ enumerable: false,
+ writable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/return-object-target.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/return-object-target.js
new file mode 100644
index 0000000000..ae9928af4b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/return-object-target.js
@@ -0,0 +1,28 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-weak-ref.prototype.deref
+description: Return an Object target if weakRef.[[Target]] is not empty
+info: |
+ WeakRef.prototype.deref ()
+ 3. Return WeakRefDeref(_weakRef_).
+
+ WeakRefDeref( _weakRef_ ):
+ 1. Let _target_ be _weakRef_.[[WeakRefTarget]].
+ 2. If _target_ is not ~empty~,
+ a. Perform AddToKeptObjects(_target_).
+ b. Return _target_.
+features: [WeakRef]
+---*/
+
+var target = {};
+var wref = new WeakRef(target);
+
+assert.sameValue(wref.deref(), target, 'returns target');
+assert.sameValue(wref.deref(), target, '[[Target]] is not emptied #1');
+assert.sameValue(wref.deref(), target, '[[Target]] is not emptied #2');
+assert.sameValue(wref.deref(), target, '[[Target]] is not emptied #3');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/return-symbol-target.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/return-symbol-target.js
new file mode 100644
index 0000000000..d8686835cd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/return-symbol-target.js
@@ -0,0 +1,29 @@
+// |reftest| shell-option(--enable-symbols-as-weakmap-keys) skip-if(release_or_beta||!this.hasOwnProperty('WeakRef')||!xulRuntime.shell) -- symbols-as-weakmap-keys is not released yet, WeakRef is not enabled unconditionally, requires shell-options
+// Copyright (C) 2022 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-weak-ref.prototype.deref
+description: Return a Symbol target if weakRef.[[Target]] is not empty
+info: |
+ WeakRef.prototype.deref ()
+ 3. Return WeakRefDeref(_weakRef_).
+
+ WeakRefDeref( _weakRef_ ):
+ 1. Let _target_ be _weakRef_.[[WeakRefTarget]].
+ 2. If _target_ is not ~empty~,
+ a. Perform AddToKeptObjects(_target_).
+ b. Return _target_.
+features: [Symbol, WeakRef, symbols-as-weakmap-keys]
+---*/
+
+var target = Symbol('a description');
+var wref = new WeakRef(target);
+
+assert.sameValue(wref.deref(), target, 'returns a regular symbol target');
+
+var wref2 = new WeakRef(Symbol.hasInstance);
+
+assert.sameValue(wref2.deref(), Symbol.hasInstance, 'returns a well-known symbol target');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/shell.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/shell.js
new file mode 100644
index 0000000000..0010a0ff72
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/shell.js
@@ -0,0 +1,59 @@
+// GENERATED, DO NOT EDIT
+// file: async-gc.js
+// Copyright (C) 2019 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: >
+ Collection of functions used to capture references cleanup from garbage collectors
+features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry, Symbol, async-functions]
+flags: [non-deterministic]
+defines: [asyncGC, asyncGCDeref, resolveAsyncGC]
+---*/
+
+function asyncGC(...targets) {
+ var finalizationRegistry = new FinalizationRegistry(() => {});
+ var length = targets.length;
+
+ for (let target of targets) {
+ finalizationRegistry.register(target, 'target');
+ target = null;
+ }
+
+ targets = null;
+
+ return Promise.resolve('tick').then(() => asyncGCDeref()).then(() => {
+ var names = [];
+
+ // consume iterator to capture names
+ finalizationRegistry.cleanupSome(name => { names.push(name); });
+
+ if (!names || names.length != length) {
+ throw asyncGC.notCollected;
+ }
+ });
+}
+
+asyncGC.notCollected = Symbol('Object was not collected');
+
+async function asyncGCDeref() {
+ var trigger;
+
+ // TODO: Remove this when $262.clearKeptObject becomes documented and required
+ if ($262.clearKeptObjects) {
+ trigger = $262.clearKeptObjects();
+ }
+
+ await $262.gc();
+
+ return Promise.resolve(trigger);
+}
+
+function resolveAsyncGC(err) {
+ if (err === asyncGC.notCollected) {
+ // Do not fail as GC can't provide necessary resources.
+ $DONE();
+ return;
+ }
+
+ $DONE(err);
+}
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-does-not-have-internal-target-throws.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-does-not-have-internal-target-throws.js
new file mode 100644
index 0000000000..a5529c5386
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-does-not-have-internal-target-throws.js
@@ -0,0 +1,53 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')||!this.hasOwnProperty('FinalizationRegistry')) -- WeakRef,FinalizationRegistry is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-weak-ref.prototype.deref
+description: Throws a TypeError if this does not have a [[Target]] internal slot
+info: |
+ WeakRef.prototype.deref ()
+
+ 1. Let weakRef be the this value.
+ 2. If Type(weakRef) is not Object, throw a TypeError exception.
+ 3. If weakRef does not have a [[Target]] internal slot, throw a TypeError exception.
+ 4. Let target be the value of weakRef.[[Target]].
+ 5. If target is not empty,
+ a. Perform ! KeepDuringJob(target).
+ b. Return target.
+ 6. Return undefined.
+features: [WeakSet, WeakMap, WeakRef, FinalizationRegistry]
+---*/
+
+assert.sameValue(typeof WeakRef.prototype.deref, 'function');
+
+var deref = WeakRef.prototype.deref;
+
+assert.throws(TypeError, function() {
+ deref.call({ ['[[Target]]']: {} });
+}, 'Ordinary object without [[Target]]');
+
+assert.throws(TypeError, function() {
+ deref.call(WeakRef.prototype);
+}, 'WeakRef.prototype does not have a [[Target]] internal slot');
+
+assert.throws(TypeError, function() {
+ deref.call(WeakRef);
+}, 'WeakRef does not have a [[Target]] internal slot');
+
+var finalizationRegistry = new FinalizationRegistry(function() {});
+assert.throws(TypeError, function() {
+ deref.call(finalizationRegistry);
+}, 'FinalizationRegistry instance');
+
+var wm = new WeakMap();
+assert.throws(TypeError, function() {
+ deref.call(wm);
+}, 'WeakMap instance');
+
+var ws = new WeakSet();
+assert.throws(TypeError, function() {
+ deref.call(ws);
+}, 'WeakSet instance');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-not-object-throws.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-not-object-throws.js
new file mode 100644
index 0000000000..7580671b5e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-not-object-throws.js
@@ -0,0 +1,55 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-weak-ref.prototype.deref
+description: Throws a TypeError if this is not an Object
+info: |
+ WeakRef.prototype.deref ()
+
+ 1. Let weakRef be the this value.
+ 2. If Type(weakRef) is not Object, throw a TypeError exception.
+ 3. If weakRef does not have a [[Target]] internal slot, throw a TypeError exception.
+ 4. Let target be the value of weakRef.[[Target]].
+ 5. If target is not empty,
+ a. Perform ! KeepDuringJob(target).
+ b. Return target.
+ 6. Return undefined.
+features: [WeakRef]
+---*/
+
+assert.sameValue(typeof WeakRef.prototype.deref, 'function');
+
+var deref = WeakRef.prototype.deref;
+
+assert.throws(TypeError, function() {
+ deref.call(undefined);
+}, 'undefined');
+
+assert.throws(TypeError, function() {
+ deref.call(null);
+}, 'null');
+
+assert.throws(TypeError, function() {
+ deref.call(true);
+}, 'true');
+
+assert.throws(TypeError, function() {
+ deref.call(false);
+}, 'false');
+
+assert.throws(TypeError, function() {
+ deref.call(1);
+}, 'number');
+
+assert.throws(TypeError, function() {
+ deref.call('object');
+}, 'string');
+
+var s = Symbol();
+assert.throws(TypeError, function() {
+ deref.call(s);
+}, 'symbol');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/prop-desc.js b/js/src/tests/test262/built-ins/WeakRef/prototype/prop-desc.js
new file mode 100644
index 0000000000..53def27b83
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/prop-desc.js
@@ -0,0 +1,21 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: The property descriptor WeakRef.prototype
+esid: sec-weak-ref.prototype
+info: |
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: false }.
+features: [WeakRef]
+includes: [propertyHelper.js]
+---*/
+
+verifyProperty(WeakRef, 'prototype', {
+ writable: false,
+ enumerable: false,
+ configurable: false
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/proto.js b/js/src/tests/test262/built-ins/WeakRef/prototype/proto.js
new file mode 100644
index 0000000000..e41d5245e4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/proto.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: The prototype of WeakRef.prototype is Object.prototype
+esid: sec-properties-of-the-weak-ref-prototype-object
+info: |
+ The value of the [[Prototype]] internal slot of the WeakRef prototype object
+ is the intrinsic object %ObjectPrototype%.
+features: [WeakRef]
+---*/
+
+var proto = Object.getPrototypeOf(WeakRef.prototype);
+assert.sameValue(proto, Object.prototype);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/shell.js b/js/src/tests/test262/built-ins/WeakRef/prototype/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakRef/prototype/shell.js