tor-browser

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

surface.js (3494B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Intl'))
      2 
      3 function assertProperty(object, name, desc) {
      4    assertEq(desc === undefined || (typeof desc === "object" && desc !== null), true,
      5             "desc is a property descriptor");
      6 
      7    var actual = Object.getOwnPropertyDescriptor(object, name);
      8    if (desc === undefined) {
      9        assertEq(actual, desc, `property ${String(name)} is absent`);
     10        return;
     11    }
     12    assertEq(actual !== undefined, true, `property ${String(name)} is present`);
     13 
     14    var fields = ["value", "writable", "enumerable", "configurable", "get", "set"];
     15    for (var field of fields) {
     16        if (Object.prototype.hasOwnProperty.call(desc, field)) {
     17            assertEq(actual[field], desc[field], `unexpected value for ${field}`);
     18        }
     19    }
     20 }
     21 
     22 function assertBuiltinFunction(fn, length, name) {
     23    assertProperty(fn, "length", {
     24       value: length, writable: false, enumerable: false, configurable: true,
     25    });
     26 }
     27 
     28 function assertBuiltinMethod(object, propName, length, name) {
     29    var desc = Object.getOwnPropertyDescriptor(object, propName);
     30    assertProperty(object, propName, {
     31        value: desc.value, writable: true, enumerable: false, configurable: true
     32    });
     33    assertBuiltinFunction(desc.value, length, name);
     34 }
     35 
     36 function assertBuiltinGetter(object, propName, length, name) {
     37    var desc = Object.getOwnPropertyDescriptor(object, propName);
     38 
     39    assertBuiltinFunction(desc.get, length, name);
     40 }
     41 
     42 // Intl.Locale( tag[, options] )
     43 assertBuiltinFunction(Intl.Locale, 1, "Locale");
     44 
     45 // Properties of the Intl.Locale Constructor
     46 
     47 // Intl.Locale.prototype
     48 assertProperty(Intl.Locale, "prototype", {
     49    value: Intl.Locale.prototype, writable: false, enumerable: false, configurable: false,
     50 });
     51 
     52 // Properties of the Intl.Locale Prototype Object
     53 
     54 // Intl.Locale.prototype.constructor
     55 assertProperty(Intl.Locale.prototype, "constructor", {
     56    value: Intl.Locale, writable: true, enumerable: false, configurable: true,
     57 });
     58 
     59 // Intl.Locale.prototype[ @@toStringTag ]
     60 assertProperty(Intl.Locale.prototype, Symbol.toStringTag, {
     61    value: "Intl.Locale", writable: false, enumerable: false, configurable: true,
     62 });
     63 
     64 // Intl.Locale.prototype.toString ()
     65 assertBuiltinMethod(Intl.Locale.prototype, "toString", 0, "toString");
     66 
     67 // get Intl.Locale.prototype.baseName
     68 assertBuiltinGetter(Intl.Locale.prototype, "baseName", 0, "get baseName");
     69 
     70 // get Intl.Locale.prototype.calendar
     71 assertBuiltinGetter(Intl.Locale.prototype, "calendar", 0, "get calendar");
     72 
     73 // get Intl.Locale.prototype.collation
     74 assertBuiltinGetter(Intl.Locale.prototype, "collation", 0, "get collation");
     75 
     76 // get Intl.Locale.prototype.hourCycle
     77 assertBuiltinGetter(Intl.Locale.prototype, "hourCycle", 0, "get hourCycle");
     78 
     79 // get Intl.Locale.prototype.caseFirst
     80 assertBuiltinGetter(Intl.Locale.prototype, "caseFirst", 0, "get caseFirst");
     81 
     82 // get Intl.Locale.prototype.numeric
     83 assertBuiltinGetter(Intl.Locale.prototype, "numeric", 0, "get numeric");
     84 
     85 // get Intl.Locale.prototype.numberingSystem
     86 assertBuiltinGetter(Intl.Locale.prototype, "numberingSystem", 0, "get numberingSystem");
     87 
     88 // get Intl.Locale.prototype.language
     89 assertBuiltinGetter(Intl.Locale.prototype, "language", 0, "get language");
     90 
     91 // get Intl.Locale.prototype.script
     92 assertBuiltinGetter(Intl.Locale.prototype, "script", 0, "get script");
     93 
     94 // get Intl.Locale.prototype.region
     95 assertBuiltinGetter(Intl.Locale.prototype, "region", 0, "get region");
     96 
     97 if (typeof reportCompare === "function")
     98    reportCompare(0, 0);