tor-browser

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

dataset-set.html (2437B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>Dataset - Set</title>
      5    <script src="/resources/testharness.js"></script>
      6    <script src="/resources/testharnessreport.js"></script>
      7  </head>
      8  <body>
      9    <h1>Dataset - Set</h1>
     10    <div id="log"></div>
     11    <script>
     12      function testSet(prop, expected)
     13      {
     14        var d = document.createElement("div");
     15        d.dataset[prop] = "value";
     16        return d.getAttribute(expected) == "value";
     17      }
     18 
     19      test(function() { assert_true(testSet('foo', 'data-foo')); },
     20        "Setting element.dataset['foo'] should also change the value of element.getAttribute('data-foo')");
     21      test(function() { assert_true(testSet('fooBar', 'data-foo-bar')); },
     22        "Setting element.dataset['fooBar'] should also change the value of element.getAttribute('data-foo-bar')");
     23      test(function() { assert_true(testSet('-', 'data--')); },
     24        "Setting element.dataset['-'] should also change the value of element.getAttribute('data--')");
     25      test(function() { assert_true(testSet('Foo', 'data--foo')); },
     26        "Setting element.dataset['Foo'] should also change the value of element.getAttribute('data--foo')");
     27      test(function() { assert_true(testSet('-Foo', 'data---foo')); },
     28        "Setting element.dataset['-Foo'] should also change the value of element.getAttribute('data---foo')");
     29      test(function() { assert_true(testSet('', 'data-')); },
     30        "Setting element.dataset[''] should also change the value of element.getAttribute('data-')");
     31      test(function() { assert_true(testSet('\xE0', 'data-\xE0')); },
     32        "Setting element.dataset['\xE0'] should also change the value of element.getAttribute('data-\xE0')");
     33      test(function() { assert_throws_dom('SYNTAX_ERR', function() { testSet('-foo', 'dummy') }); },
     34        "Setting element.dataset['-foo'] should throw a SYNTAX_ERR");
     35      test(function() { assert_throws_dom('INVALID_CHARACTER_ERR', function() { testSet('foo\x20', 'dummy') }); },
     36        "Setting element.dataset['foo\x20'] should throw an INVALID_CHARACTER_ERR");
     37      test(function() { assert_true(testSet('\u037Efoo', 'data-\u037Efoo')); },
     38        "Setting element.dataset['\u037Efoo'] should not throw.");
     39      test(function() { assert_true(testSet('\u0BC6foo', 'data-\u0BC6foo')); },
     40        "Setting element.dataset['\u0BC6foo'] should also change the value of element.getAttribute('\u0BC6foo')");
     41 
     42    </script>
     43  </body>
     44 </html>