tor-browser

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

browser_freeze_builtins.js (963B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 */
      5 
      6 function checkCtor(global, name, description) {
      7  ok(Object.isFrozen(global[name]), `${description} ${name} is frozen`);
      8  ok(
      9    Object.isSealed(global[name].prototype),
     10    `${description} ${name}.prototype is sealed`
     11  );
     12 
     13  let descr = Object.getOwnPropertyDescriptor(global, name);
     14  ok(!descr.configurable, `${description} ${name} should be non-configurable`);
     15  ok(!descr.writable, `${description} ${name} should not be writable`);
     16 }
     17 
     18 function checkGlobal(global, description) {
     19  checkCtor(global, "Object", description);
     20  checkCtor(global, "Array", description);
     21  checkCtor(global, "Function", description);
     22 }
     23 
     24 add_task(async function () {
     25  let systemGlobal = Cu.getGlobalForObject(Services);
     26  checkGlobal(systemGlobal, "system global");
     27 });