summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register')
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/custom-this.js31
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/heldValue-same-as-target.js38
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/holdings-any-value-type.js38
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/length.js35
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/name.js34
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/not-a-constructor.js36
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/prop-desc.js27
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/return-undefined-register-itself.js33
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/return-undefined-register-object.js46
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/return-undefined-register-symbol.js76
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/this-does-not-have-internal-target-throws.js51
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/this-not-object-throws.js54
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/throws-when-target-cannot-be-held-weakly.js47
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/throws-when-unregisterToken-not-undefined-and-cannot-be-held-weakly.js47
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/unregisterToken-same-as-holdings-and-target.js30
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/unregisterToken-same-as-holdings.js30
-rw-r--r--js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/unregisterToken-same-as-target.js29
19 files changed, 682 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/browser.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/browser.js
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/custom-this.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/custom-this.js
new file mode 100644
index 0000000000..fa1df025da
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/custom-this.js
@@ -0,0 +1,31 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: Return undefined (applying custom this)
+info: |
+ FinalizationRegistry.prototype.register ( target , holdings [, unregisterToken ] )
+
+ 1. Let finalizationRegistry be the this value.
+ 2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
+ 3. If Type(target) is not Object, throw a TypeError exception.
+ 4. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
+ 5. If Type(unregisterToken) is not Object,
+ a. If unregisterToken is not undefined, throw a TypeError exception.
+ b. Set unregisterToken to empty.
+ 6. Let cell be the Record { [[Target]] : target, [[Holdings]]: holdings, [[UnregisterToken]]: unregisterToken }.
+ 7. Append cell to finalizationRegistry.[[Cells]].
+ 8. Return undefined.
+features: [FinalizationRegistry]
+---*/
+
+var fn = function() {};
+var register = FinalizationRegistry.prototype.register;
+var finalizationRegistry = new FinalizationRegistry(fn);
+
+var target = {};
+assert.sameValue(register.call(finalizationRegistry, target), undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/heldValue-same-as-target.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/heldValue-same-as-target.js
new file mode 100644
index 0000000000..11c8142074
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/heldValue-same-as-target.js
@@ -0,0 +1,38 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: heldValue may be the same as target
+info: |
+ FinalizationRegistry.prototype.register ( _target_ , _heldValue_ [, _unregisterToken_ ] )
+ 1. Let _finalizationRegistry_ be the *this* value.
+ 2. Perform ? RequireInternalSlot(_finalizationRegistry_, [[Cells]]).
+ 3. If CanBeHeldWeakly(_target_) is *false*, throw a *TypeError* exception.
+ 4. If SameValue(_target_, _heldValue_) is *true*, throw a *TypeError* exception.
+features: [FinalizationRegistry, Symbol]
+---*/
+
+var finalizationRegistry = new FinalizationRegistry(function() {});
+
+var target = {};
+assert.throws(TypeError, () => finalizationRegistry.register(target, target));
+
+// The following will throw regardless of whether the implementation supports
+// Symbols as weak values. Step 3 if no, Step 4 if yes.
+
+var symbolTarget = Symbol('a description');
+assert.throws(
+ TypeError,
+ () => finalizationRegistry.register(symbolTarget, symbolTarget),
+ 'target and heldValue are the same regular symbol'
+);
+
+assert.throws(
+ TypeError,
+ () => finalizationRegistry.register(Symbol.hasInstance, Symbol.hasInstance),
+ 'target and heldValue are the same well-known symbol'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/holdings-any-value-type.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/holdings-any-value-type.js
new file mode 100644
index 0000000000..87dacdbb34
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/holdings-any-value-type.js
@@ -0,0 +1,38 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: No restriction for the value or type of holdings
+info: |
+ FinalizationRegistry.prototype.register ( target , holdings [, unregisterToken ] )
+
+ 1. Let finalizationRegistry be the this value.
+ 2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
+ 3. If Type(target) is not Object, throw a TypeError exception.
+ 4. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
+ 5. If Type(unregisterToken) is not Object,
+ a. If unregisterToken is not undefined, throw a TypeError exception.
+ b. Set unregisterToken to empty.
+ 6. Let cell be the Record { [[Target]] : target, [[Holdings]]: holdings, [[UnregisterToken]]: unregisterToken }.
+ 7. Append cell to finalizationRegistry.[[Cells]].
+ 8. Return undefined.
+features: [FinalizationRegistry]
+---*/
+
+var fn = function() {};
+var finalizationRegistry = new FinalizationRegistry(fn);
+
+var target = {};
+assert.sameValue(finalizationRegistry.register(target, undefined), undefined, 'undefined');
+assert.sameValue(finalizationRegistry.register(target, null), undefined, 'null');
+assert.sameValue(finalizationRegistry.register(target, false), undefined, 'false');
+assert.sameValue(finalizationRegistry.register(target, true), undefined, 'true');
+assert.sameValue(finalizationRegistry.register(target, Symbol()), undefined, 'symbol');
+assert.sameValue(finalizationRegistry.register(target, {}), undefined, 'object');
+assert.sameValue(finalizationRegistry.register(target, finalizationRegistry), undefined, 'same as finalizationRegistry instance');
+assert.sameValue(finalizationRegistry.register(target, 1), undefined, 'number');
+assert.sameValue(finalizationRegistry.register(target, 'holdings'), undefined, 'string');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/length.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/length.js
new file mode 100644
index 0000000000..6b33da1d3c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/length.js
@@ -0,0 +1,35 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: FinalizationRegistry.prototype.register.length property descriptor
+info: |
+ FinalizationRegistry.prototype.register ( target , holdings [, unregisterToken ] )
+
+ 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: [FinalizationRegistry]
+---*/
+
+verifyProperty(FinalizationRegistry.prototype.register, 'length', {
+ value: 2,
+ enumerable: false,
+ writable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/name.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/name.js
new file mode 100644
index 0000000000..7296b1a76f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/name.js
@@ -0,0 +1,34 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: FinalizationRegistry.prototype.register.name property descriptor
+info: |
+ FinalizationRegistry.prototype.register.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: [FinalizationRegistry]
+---*/
+
+verifyProperty(FinalizationRegistry.prototype.register, 'name', {
+ value: 'register',
+ enumerable: false,
+ writable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/not-a-constructor.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/not-a-constructor.js
new file mode 100644
index 0000000000..f2471782ab
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/not-a-constructor.js
@@ -0,0 +1,36 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- FinalizationRegistry 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: >
+ FinalizationRegistry.prototype.register 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, FinalizationRegistry, arrow-function]
+---*/
+
+assert.sameValue(
+ isConstructor(FinalizationRegistry.prototype.register),
+ false,
+ 'isConstructor(FinalizationRegistry.prototype.register) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let fr = new FinalizationRegistry(() => {}); new fr.register({});
+}, '`let fr = new FinalizationRegistry(() => {}); new fr.register({})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/prop-desc.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/prop-desc.js
new file mode 100644
index 0000000000..22bb9a3298
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/prop-desc.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: >
+ Property descriptor of FinalizationRegistry.prototype.register
+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: [FinalizationRegistry]
+---*/
+
+assert.sameValue(typeof FinalizationRegistry.prototype.register, 'function');
+
+verifyProperty(FinalizationRegistry.prototype, 'register', {
+ enumerable: false,
+ writable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/return-undefined-register-itself.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/return-undefined-register-itself.js
new file mode 100644
index 0000000000..00efa55a0a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/return-undefined-register-itself.js
@@ -0,0 +1,33 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: Return undefined after registering itself
+info: |
+ FinalizationRegistry.prototype.register ( target , holdings [, unregisterToken ] )
+
+ 1. Let finalizationRegistry be the this value.
+ 2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
+ 3. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
+ 4. If Type(target) is not Object, throw a TypeError exception.
+ 5. If SameValue(target, holdings), throw a TypeError exception.
+ 6. If Type(unregisterToken) is not Object,
+ a. If unregisterToken is not undefined, throw a TypeError exception.
+ b. Set unregisterToken to empty.
+ 7. Let cell be the Record { [[Target]] : target, [[Holdings]]: holdings, [[UnregisterToken]]: unregisterToken }.
+ 8. Append cell to finalizationRegistry.[[Cells]].
+ 9. Return undefined.
+features: [FinalizationRegistry]
+---*/
+
+var fn = function() {};
+var finalizationRegistry = new FinalizationRegistry(fn);
+var holdings = {};
+
+assert.sameValue(finalizationRegistry.register(finalizationRegistry), undefined, 'Register itself');
+assert.sameValue(finalizationRegistry.register(finalizationRegistry, holdings), undefined, 'Register itself with holdings');
+assert.sameValue(finalizationRegistry.register(finalizationRegistry, holdings, finalizationRegistry), undefined, 'Register itself with holdings and unregisterToken');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/return-undefined-register-object.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/return-undefined-register-object.js
new file mode 100644
index 0000000000..b185a37113
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/return-undefined-register-object.js
@@ -0,0 +1,46 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: Return undefined after registering an Object
+info: |
+ FinalizationRegistry.prototype.register ( _target_ , _heldValue_ [, _unregisterToken_ ] )
+ 1. Let _finalizationRegistry_ be the *this* value.
+ 2. Perform ? RequireInternalSlot(_finalizationRegistry_, [[Cells]]).
+ 3. If CanBeHeldWeakly(_target_) is *false*, throw a *TypeError* exception.
+ 4. If SameValue(_target_, _heldValue_) is *true*, throw a *TypeError*
+ exception.
+ 5. If CanBeHeldWeakly(_unregisterToken_) is *false*,
+ a. If _unregisterToken_ is not *undefined*, throw a *TypeError* exception.
+ b. Set _unregisterToken_ to ~empty~.
+ 6. Let _cell_ be the Record { [[WeakRefTarget]]: _target_, [[HeldValue]]:
+ _heldValue_, [[UnregisterToken]]: _unregisterToken_ }.
+ 7. Append _cell_ to _finalizationRegistry_.[[Cells]].
+ 8. Return *undefined*.
+features: [FinalizationRegistry]
+---*/
+
+var fn = function() {};
+var finalizationRegistry = new FinalizationRegistry(fn);
+
+var target = {};
+assert.sameValue(finalizationRegistry.register(target), undefined, 'Register a target');
+assert.sameValue(finalizationRegistry.register(target), undefined, 'Register the same target again');
+assert.sameValue(finalizationRegistry.register(target), undefined, 'Register the same target again and again');
+
+assert.sameValue(finalizationRegistry.register({}), undefined, 'Register other targets');
+
+assert.sameValue(finalizationRegistry.register(target, undefined, {}), undefined, 'Register target with unregisterToken');
+assert.sameValue(
+ finalizationRegistry.register(target, undefined, target),
+ undefined,
+ 'Register target with unregisterToken being the registered target'
+);
+
+assert.sameValue(finalizationRegistry.register(target, undefined, undefined), undefined, 'Register target with explicit undefined unregisterToken');
+
+assert.sameValue(finalizationRegistry.register(fn), undefined, 'register the cleanup callback fn');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/return-undefined-register-symbol.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/return-undefined-register-symbol.js
new file mode 100644
index 0000000000..8c8a944429
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/return-undefined-register-symbol.js
@@ -0,0 +1,76 @@
+// |reftest| shell-option(--enable-symbols-as-weakmap-keys) skip-if(release_or_beta||!this.hasOwnProperty('FinalizationRegistry')||!xulRuntime.shell) -- symbols-as-weakmap-keys is not released yet, FinalizationRegistry 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-finalization-registry.prototype.register
+description: Return undefined after registering a Symbol
+info: |
+ FinalizationRegistry.prototype.register ( _target_ , _heldValue_ [, _unregisterToken_ ] )
+ 8. Return *undefined*.
+features: [FinalizationRegistry, Symbol, symbols-as-weakmap-keys]
+---*/
+
+var fn = function() {};
+var reg = new FinalizationRegistry(fn);
+
+var target = Symbol('a description');
+assert.sameValue(reg.register(target), undefined, 'Register a regular symbol');
+assert.sameValue(reg.register(target), undefined, 'Register the same symbol again');
+assert.sameValue(reg.register(target), undefined, 'Register the same symbol a third time');
+
+assert.sameValue(
+ reg.register(Symbol('a description')),
+ undefined,
+ 'Register another symbol with the same description'
+);
+assert.sameValue(
+ reg.register(Symbol('a different description')),
+ undefined,
+ 'Register another symbol with another description'
+);
+
+assert.sameValue(
+ reg.register(target, undefined, Symbol('unregister token')),
+ undefined,
+ 'Register a regular symbol with a symbol unregister token'
+);
+assert.sameValue(
+ reg.register(target, undefined, target),
+ undefined,
+ 'Register a regular symbol with itself as the unregister token'
+);
+
+assert.sameValue(
+ reg.register(target, undefined, undefined),
+ undefined,
+ 'Register a regular symbol with explicit undefined unregister token'
+);
+
+assert.sameValue(reg.register(Symbol.hasInstance), undefined, 'Register a well-known symbol');
+assert.sameValue(reg.register(Symbol.hasInstance), undefined, 'Register the same well-known symbol again');
+assert.sameValue(reg.register(Symbol.hasInstance), undefined, 'Register the same well-known symbol a third time');
+
+assert.sameValue(
+ reg.register(target, undefined, Symbol.hasInstance),
+ undefined,
+ 'Register a regular symbol with a well-known symbol unregister token'
+);
+assert.sameValue(
+ reg.register(Symbol.hasInstance, undefined, Symbol.iterator),
+ undefined,
+ 'Register a well-known symbol with a different well-known symbol as unregister token'
+);
+assert.sameValue(
+ reg.register(Symbol.hasInstance, undefined, Symbol.hasInstance),
+ undefined,
+ 'Register a well-known symbol with itself as the unregister token'
+);
+
+assert.sameValue(
+ reg.register(Symbol.hasInstance, undefined, undefined),
+ undefined,
+ 'Register a well-known symbol with explicit undefined unregister token'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/shell.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/shell.js
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/this-does-not-have-internal-target-throws.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/this-does-not-have-internal-target-throws.js
new file mode 100644
index 0000000000..f7044833ba
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/this-does-not-have-internal-target-throws.js
@@ -0,0 +1,51 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')||!this.hasOwnProperty('WeakRef')) -- FinalizationRegistry,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-finalization-registry.prototype.register
+description: Throws a TypeError if this does not have a [[Cells]] internal slot
+info: |
+ FinalizationRegistry.prototype.register ( target , holdings [, unregisterToken ] )
+
+ 1. Let finalizationRegistry be the this value.
+ 2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
+ 3. If Type(target) is not Object, throw a TypeError exception.
+ 4. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
+ ...
+features: [WeakSet, WeakMap, FinalizationRegistry, WeakRef]
+---*/
+
+assert.sameValue(typeof FinalizationRegistry.prototype.register, 'function');
+
+var register = FinalizationRegistry.prototype.register;
+var target = {};
+
+assert.throws(TypeError, function() {
+ register.call({ ['[[Cells]]']: {} }, target);
+}, 'Ordinary object without [[Cells]]');
+
+assert.throws(TypeError, function() {
+ register.call(WeakRef.prototype, target);
+}, 'WeakRef.prototype does not have a [[Cells]] internal slot');
+
+assert.throws(TypeError, function() {
+ register.call(WeakRef, target);
+}, 'WeakRef does not have a [[Cells]] internal slot');
+
+var wr = new WeakRef({});
+assert.throws(TypeError, function() {
+ register.call(wr, target);
+}, 'WeakRef instance');
+
+var wm = new WeakMap();
+assert.throws(TypeError, function() {
+ register.call(wm, target);
+}, 'WeakMap instance');
+
+var ws = new WeakSet();
+assert.throws(TypeError, function() {
+ register.call(ws, target);
+}, 'WeakSet instance');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/this-not-object-throws.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/this-not-object-throws.js
new file mode 100644
index 0000000000..933a905e35
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/this-not-object-throws.js
@@ -0,0 +1,54 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: Throws a TypeError if this is not an Object
+info: |
+ FinalizationRegistry.prototype.register ( target , holdings [, unregisterToken ] )
+
+ 1. Let finalizationRegistry be the this value.
+ 2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
+ 3. If Type(target) is not Object, throw a TypeError exception.
+ 4. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
+ 5. If Type(unregisterToken) is not Object,
+ a. If unregisterToken is not undefined, throw a TypeError exception.
+ ...
+features: [FinalizationRegistry]
+---*/
+
+assert.sameValue(typeof FinalizationRegistry.prototype.register, 'function');
+
+var register = FinalizationRegistry.prototype.register;
+
+assert.throws(TypeError, function() {
+ register.call(undefined, {});
+}, 'undefined');
+
+assert.throws(TypeError, function() {
+ register.call(null, {});
+}, 'null');
+
+assert.throws(TypeError, function() {
+ register.call(true, {});
+}, 'true');
+
+assert.throws(TypeError, function() {
+ register.call(false, {});
+}, 'false');
+
+assert.throws(TypeError, function() {
+ register.call(1, {});
+}, 'number');
+
+assert.throws(TypeError, function() {
+ register.call('object', {});
+}, 'string');
+
+var s = Symbol();
+assert.throws(TypeError, function() {
+ register.call(s, {});
+}, 'symbol');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/throws-when-target-cannot-be-held-weakly.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/throws-when-target-cannot-be-held-weakly.js
new file mode 100644
index 0000000000..fa2fe3e021
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/throws-when-target-cannot-be-held-weakly.js
@@ -0,0 +1,47 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: Throws a TypeError if target cannot be held weakly
+info: |
+ FinalizationRegistry.prototype.register ( _target_ , _heldValue_ [, _unregisterToken_ ] )
+ 3. If CanBeHeldWeakly(_target_) is *false*, throw a *TypeError* exception.
+features: [FinalizationRegistry]
+---*/
+
+assert.sameValue(typeof FinalizationRegistry.prototype.register, 'function');
+
+var finalizationRegistry = new FinalizationRegistry(function() {});
+
+assert.throws(TypeError, function() {
+ finalizationRegistry.register(undefined);
+}, 'undefined');
+
+assert.throws(TypeError, function() {
+ finalizationRegistry.register(null);
+}, 'null');
+
+assert.throws(TypeError, function() {
+ finalizationRegistry.register(true);
+}, 'true');
+
+assert.throws(TypeError, function() {
+ finalizationRegistry.register(false);
+}, 'false');
+
+assert.throws(TypeError, function() {
+ finalizationRegistry.register(1);
+}, 'number');
+
+assert.throws(TypeError, function() {
+ finalizationRegistry.register('object');
+}, 'string');
+
+var s = Symbol.for('registered symbol');
+assert.throws(TypeError, function() {
+ finalizationRegistry.register(s);
+}, 'registered symbol');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/throws-when-unregisterToken-not-undefined-and-cannot-be-held-weakly.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/throws-when-unregisterToken-not-undefined-and-cannot-be-held-weakly.js
new file mode 100644
index 0000000000..6f7853a439
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/throws-when-unregisterToken-not-undefined-and-cannot-be-held-weakly.js
@@ -0,0 +1,47 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: >
+ Throws a TypeError if unregisterToken is not undefined and cannot be held
+ weakly
+info: |
+ FinalizationRegistry.prototype.register ( _target_ , _heldValue_ [, _unregisterToken_ ] )
+ 5. If CanBeHeldWeakly(_unregisterToken_) is *false*, then
+ a. If _unregisterToken_ is not *undefined*, throw a *TypeError* exception.
+features: [FinalizationRegistry]
+---*/
+
+assert.sameValue(typeof FinalizationRegistry.prototype.register, 'function');
+
+var finalizationRegistry = new FinalizationRegistry(function() {});
+var target = {};
+
+assert.throws(TypeError, function() {
+ finalizationRegistry.register(target, undefined, null);
+}, 'null');
+
+assert.throws(TypeError, function() {
+ finalizationRegistry.register(target, undefined, true);
+}, 'true');
+
+assert.throws(TypeError, function() {
+ finalizationRegistry.register(target, undefined, false);
+}, 'false');
+
+assert.throws(TypeError, function() {
+ finalizationRegistry.register(target, undefined, 1);
+}, 'number');
+
+assert.throws(TypeError, function() {
+ finalizationRegistry.register(target, undefined, 'object');
+}, 'string');
+
+var s = Symbol.for('registered symbol');
+assert.throws(TypeError, function() {
+ finalizationRegistry.register(target, undefined, s);
+}, 'registered symbol');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/unregisterToken-same-as-holdings-and-target.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/unregisterToken-same-as-holdings-and-target.js
new file mode 100644
index 0000000000..a3ed546406
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/unregisterToken-same-as-holdings-and-target.js
@@ -0,0 +1,30 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: unregisterToken may be the same as holdings and target
+info: |
+ FinalizationRegistry.prototype.register ( target , holdings [, unregisterToken ] )
+
+ 1. Let finalizationRegistry be the this value.
+ 2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
+ 3. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
+ 4. If Type(target) is not Object, throw a TypeError exception.
+ 5. If SameValue(target, holdings), throw a TypeError exception.
+ 6. If Type(unregisterToken) is not Object,
+ a. If unregisterToken is not undefined, throw a TypeError exception.
+ b. Set unregisterToken to empty.
+ 7. Let cell be the Record { [[Target]] : target, [[Holdings]]: holdings, [[UnregisterToken]]: unregisterToken }.
+ 8. Append cell to finalizationRegistry.[[Cells]].
+ 9. Return undefined.
+features: [FinalizationRegistry]
+---*/
+
+var finalizationRegistry = new FinalizationRegistry(function() {});
+
+var target = {};
+assert.throws(TypeError, () => finalizationRegistry.register(target, target, target));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/unregisterToken-same-as-holdings.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/unregisterToken-same-as-holdings.js
new file mode 100644
index 0000000000..befc50ec10
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/unregisterToken-same-as-holdings.js
@@ -0,0 +1,30 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: unregisterToken may be the same as holdings
+info: |
+ FinalizationRegistry.prototype.register ( target , holdings [, unregisterToken ] )
+
+ 1. Let finalizationRegistry be the this value.
+ 2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
+ 3. If Type(target) is not Object, throw a TypeError exception.
+ 4. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
+ 5. If Type(unregisterToken) is not Object,
+ a. If unregisterToken is not undefined, throw a TypeError exception.
+ b. Set unregisterToken to empty.
+ 6. Let cell be the Record { [[Target]] : target, [[Holdings]]: holdings, [[UnregisterToken]]: unregisterToken }.
+ 7. Append cell to finalizationRegistry.[[Cells]].
+ 8. Return undefined.
+features: [FinalizationRegistry]
+---*/
+
+var finalizationRegistry = new FinalizationRegistry(function() {});
+
+var target = {};
+var holdings = {};
+assert.sameValue(finalizationRegistry.register(target, holdings, holdings), undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/unregisterToken-same-as-target.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/unregisterToken-same-as-target.js
new file mode 100644
index 0000000000..bfe567cf50
--- /dev/null
+++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/unregisterToken-same-as-target.js
@@ -0,0 +1,29 @@
+// |reftest| skip-if(!this.hasOwnProperty('FinalizationRegistry')) -- 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-finalization-registry.prototype.register
+description: unregisterToken may be the same as target
+info: |
+ FinalizationRegistry.prototype.register ( target , holdings [, unregisterToken ] )
+
+ 1. Let finalizationRegistry be the this value.
+ 2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
+ 3. If Type(target) is not Object, throw a TypeError exception.
+ 4. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
+ 5. If Type(unregisterToken) is not Object,
+ a. If unregisterToken is not undefined, throw a TypeError exception.
+ b. Set unregisterToken to empty.
+ 6. Let cell be the Record { [[Target]] : target, [[Holdings]]: holdings, [[UnregisterToken]]: unregisterToken }.
+ 7. Append cell to finalizationRegistry.[[Cells]].
+ 8. Return undefined.
+features: [FinalizationRegistry]
+---*/
+
+var finalizationRegistry = new FinalizationRegistry(function() {});
+
+var target = {};
+assert.sameValue(finalizationRegistry.register(target, '1', target), undefined);
+
+reportCompare(0, 0);