tor-browser

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

subclassing.js (868B)


      1 // Copyright 2018 Igalia, S.L. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-Intl.Locale
      6 description: Checks that Locale can be subclassed.
      7 info: |
      8    Intl.Locale( tag [, options] )
      9 
     10    6. Let locale be ? OrdinaryCreateFromConstructor(NewTarget, %LocalePrototype%, internalSlotsList).
     11 
     12 features: [Intl.Locale]
     13 ---*/
     14 
     15 class CustomLocale extends Intl.Locale {
     16  constructor(locales, options) {
     17    super(locales, options);
     18    this.isCustom = true;
     19  }
     20 }
     21 
     22 var locale = new CustomLocale("de");
     23 assert.sameValue(locale.isCustom, true, "Custom property");
     24 assert.sameValue(locale.toString(), "de", "Direct call");
     25 assert.sameValue(Intl.Locale.prototype.toString.call(locale), "de", "Indirect call");
     26 assert.sameValue(Object.getPrototypeOf(locale), CustomLocale.prototype, "Prototype");
     27 
     28 reportCompare(0, 0);