tor-browser

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

prevent-extensions.js (898B)


      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 es6id: 26.1.12
      5 description: >
      6  Prevent extentions on target.
      7 info: |
      8  26.1.12 Reflect.preventExtensions ( target )
      9 
     10  ...
     11  2. Return target.[[PreventExtensions]]().
     12 
     13  9.1.4 [[PreventExtensions]] ( )
     14 
     15  1. Set the value of the [[Extensible]] internal slot of O to false.
     16  ...
     17 features: [Reflect]
     18 ---*/
     19 
     20 var o = {};
     21 Reflect.preventExtensions(o);
     22 assert.sameValue(Object.isExtensible(o), false, 'object is not extensible');
     23 
     24 assert.throws(TypeError, function() {
     25  Object.defineProperty(o, 'y', {});
     26 });
     27 assert.throws(TypeError, function() {
     28  Object.setPrototypeOf(o, Array.prototype);
     29 });
     30 
     31 Reflect.preventExtensions(o);
     32 assert.sameValue(
     33  Object.isExtensible(o), false,
     34  'object is still not extensible on exhausted calls'
     35 );
     36 
     37 reportCompare(0, 0);