tor-browser

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

location-non-configurable-toString-valueOf.html (1142B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Same-origin Location objects have non-configurable "toString" and "valueOf" properties</title>
      4 <link rel="help" href="https://html.spec.whatwg.org/multipage/history.html#location-defineownproperty">
      5 
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 
      9 <script>
     10 "use strict";
     11 
     12 test(() => {
     13  assert_own_property(location, "toString");
     14  const origToString = location.toString;
     15 
     16  assert_throws_js(TypeError, () => {
     17    Object.defineProperty(location, "toString", {
     18      get() {},
     19      set(_v) {},
     20      enumerable: true,
     21      configurable: true,
     22    });
     23  });
     24 
     25  assert_equals(location.toString, origToString);
     26 }, "'toString' redefinition with accessor fails");
     27 
     28 test(() => {
     29  assert_own_property(location, "valueOf");
     30  const origValueOf = location.valueOf;
     31 
     32  assert_throws_js(TypeError, () => {
     33    Object.defineProperty(location, "valueOf", {
     34      get() {},
     35      enumerable: false,
     36      configurable: true,
     37    });
     38  });
     39 
     40  assert_equals(location.valueOf, origValueOf);
     41 }, "'valueOf' redefinition with accessor fails");
     42 </script>