tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

from-regexp-like-get-ctor-err.js (1345B)


      1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: >
      6    Behavior when accessing `constructor` property of RegExp-like objects
      7 es6id: 21.2.3.1
      8 info: |
      9    1. Let patternIsRegExp be IsRegExp(pattern).
     10    [...]
     11    3. If NewTarget is not undefined, let newTarget be NewTarget.
     12    4. Else,
     13       a. Let newTarget be the active function object.
     14       b. If patternIsRegExp is true and flags is undefined, then
     15          i. Let patternConstructor be Get(pattern, "constructor").
     16          ii. ReturnIfAbrupt(patternConstructor).
     17          iii. If SameValue(newTarget, patternConstructor) is true, return
     18               pattern.
     19 features: [Symbol, Symbol.match]
     20 ---*/
     21 
     22 var obj = Object.defineProperty({}, 'constructor', {
     23  get: function() {
     24    throw new Test262Error();
     25  }
     26 });
     27 
     28 obj[Symbol.match] = true;
     29 assert.throws(Test262Error, function() {
     30  RegExp(obj);
     31 });
     32 
     33 obj[Symbol.match] = 'string';
     34 assert.throws(Test262Error, function() {
     35  RegExp(obj);
     36 });
     37 
     38 obj[Symbol.match] = [];
     39 assert.throws(Test262Error, function() {
     40  RegExp(obj);
     41 });
     42 
     43 obj[Symbol.match] = Symbol()
     44 assert.throws(Test262Error, function() {
     45  RegExp(obj);
     46 });
     47 
     48 obj[Symbol.match] = 86;
     49 assert.throws(Test262Error, function() {
     50  RegExp(obj);
     51 });
     52 
     53 reportCompare(0, 0);