tor-browser

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

SharedWorker-constructor.html (2236B)


      1 <!DOCTYPE html>
      2 <title>Test SharedWorker constructor functionality.</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script>
      6 
      7 test(() => {
      8  assert_throws_js(Error,
      9                   function() {
     10                     new SharedWorker({toString:function(){throw new Error()}}, "name") },
     11                   "toString exception not propagated");
     12 }, "Test toString exception propagated correctly.");
     13 
     14 test(() => {
     15  assert_throws_js(RangeError,
     16                   function() {
     17                     var foo = {toString:function(){new Worker(foo)}}
     18                     new SharedWorker(foo, name); },
     19                   "Trying to create workers recursively did not result in an exception.");
     20 }, "Test recursive worker creation results in exception.");
     21 
     22 test(() => {
     23  assert_throws_js(TypeError,
     24                   function() { new SharedWorker(); },
     25                   "Invoking SharedWorker constructor without arguments did not result in an exception.");
     26 }, "Test SharedWorker creation without arguments results in exception.");
     27 
     28 test(() => {
     29  try {
     30    var worker = new SharedWorker("support/SharedWorker-common.js");
     31  } catch (ex) {
     32    assert_unreached("Constructor failed when no name is passed: (" + ex + ")");
     33  }
     34 }, "Test SharedWorker constructor without a name does not result in an exception.");
     35 
     36 test(() => {
     37  try {
     38    var worker = new SharedWorker("support/SharedWorker-common.js", null);
     39  } catch (ex) {
     40    assert_unreached("Constructor failed when null name is passed: (" + ex + ")");
     41  }
     42 }, "Test SharedWorker constructor with null name does not result in an exception.");
     43 
     44 test(() => {
     45  try {
     46    var worker = new SharedWorker("support/SharedWorker-common.js", undefined);
     47  } catch (ex) {
     48    assert_unreached("Constructor failed when undefined name is passed: (" + ex + ")");
     49  }
     50 }, "Test SharedWorker constructor with undefined name does not result in an exception.");
     51 
     52 test(() => {
     53  try {
     54    var worker = new SharedWorker("support/SharedWorker-common.js", "name");
     55  } catch (ex) {
     56    assert_unreached("Invoking SharedWorker constructor resulted in an exception: (" + ex + ")");
     57  }
     58 }, "Test SharedWorker constructor suceeds.");
     59 
     60 </script>