tor-browser

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

Set.html (4596B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Legacy platform objects [[Set]] method</title>
      4 <link rel="help" href="https://webidl.spec.whatwg.org/#legacy-platform-object-set">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script>
      8    test(function() {
      9        var element = document.createElement("div");
     10        element.appendChild(document.createElement("div"));
     11        element.childNodes["5"] = "foo";
     12        assert_equals(element.childNodes["5"], undefined);
     13    }, "must not set the property value when assigning to a numeric property on an object which implements an indexed property getter but not a setter when not in strict mode");
     14 
     15    test(function() {
     16        "use strict";
     17        var element = document.createElement("div");
     18        element.appendChild(document.createElement("div"));
     19        assert_throws_js(TypeError, function() { element.childNodes["5"] = "foo"; });
     20    }, "must throw when assigning to a numeric property on an object which implements a indexed property getter but not a setter in strict mode");
     21 
     22    test(function() {
     23        var element = document.createElement("div");
     24        element.attributes.foo = "foo";
     25        assert_equals(element.attributes.foo, "foo");
     26    }, "must allow assigning to a named property on an object which implements a named property getter but not a setter when not in strict mode");
     27 
     28    test(function() {
     29        "use strict";
     30        var element = document.createElement("div");
     31        element.attributes.foo = "foo";
     32        assert_equals(element.attributes.foo, "foo");
     33    }, "must allow assigning to a named property on an object which implements a named property getter but not a setter in strict mode");
     34 
     35    test(function() {
     36        "use strict";
     37        var form = document.createElement("form");
     38        assert_equals(form.method, "get");
     39        var input = document.createElement("input");
     40        input.name = "method";
     41        input.id = "method";
     42        form.appendChild(input);
     43        assert_equals(form.method, input);
     44        form.method = "post";
     45        assert_equals(form.method, input);
     46        input.remove();
     47        assert_equals(form.method, "post");
     48    }, "must allow setting built-in property on a [LegacyOverrideBuiltIns] object even if a named property shadows it");
     49 
     50    var symbol = Symbol();
     51 
     52    test(function() {
     53        var element = document.createElement("div");
     54        element.appendChild(document.createElement("div"));
     55        element.childNodes[symbol] = "foo";
     56        assert_equals(element.childNodes[symbol], "foo");
     57    }, "must allow assigning to a symbol property on an object which implements an indexed property getter but not a setter when not in strict mode");
     58 
     59    test(function() {
     60        "use strict";
     61        var element = document.createElement("div");
     62        element.appendChild(document.createElement("div"));
     63        element.childNodes[symbol] = "foo";
     64        assert_equals(element.childNodes[symbol], "foo");
     65    }, "must allow assigning to a symbol property on an object which implements an indexed property getter but not a setter in strict mode");
     66 
     67    test(function() {
     68        var element = document.createElement("div");
     69        element.attributes[symbol] = "foo";
     70        assert_equals(element.attributes[symbol], "foo");
     71    }, "must allow assigning to a symbol property on an object which implements indexed and named property getters but no setters when not in strict mode");
     72 
     73    test(function() {
     74        "use strict";
     75        var element = document.createElement("div");
     76        element.attributes[symbol] = "foo";
     77        assert_equals(element.attributes[symbol], "foo");
     78    }, "must allow assigning to a symbol property on an object which implements indexed and named property getters but no setters in strict mode");
     79 
     80    test(function() {
     81        sessionStorage.clear();
     82        this.add_cleanup(function() { sessionStorage.clear(); });
     83        sessionStorage[symbol] = "foo";
     84        assert_equals(sessionStorage[symbol], "foo");
     85    }, "must allow assigning to a symbol property on an object which implements indexed and named property getters and setters when not in strict mode");
     86 
     87    test(function() {
     88        "use strict";
     89        sessionStorage.clear();
     90        this.add_cleanup(function() { sessionStorage.clear(); });
     91        sessionStorage[symbol] = "foo";
     92        assert_equals(sessionStorage[symbol], "foo");
     93    }, "must allow assigning to a symbol property on an object which implements indexed and named property getters and setters in strict mode");
     94 </script>