tor-browser

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

interface.any.js (1920B)


      1 test(() => assert_throws_js(TypeError, () => new BroadcastChannel()),
      2  'Should throw if no name is provided');
      3 
      4 test(() => {
      5    let c = new BroadcastChannel(null);
      6    assert_equals(c.name, 'null');
      7  }, 'Null name should not throw');
      8 
      9 test(() => {
     10    let c = new BroadcastChannel(undefined);
     11    assert_equals(c.name, 'undefined');
     12  }, 'Undefined name should not throw');
     13 
     14 test(() => {
     15    let c = new BroadcastChannel('fooBar');
     16    assert_equals(c.name, 'fooBar');
     17  }, 'Non-empty name should not throw');
     18 
     19 test(() => {
     20    let c = new BroadcastChannel(123);
     21    assert_equals(c.name, '123');
     22  }, 'Non-string name should not throw');
     23 
     24 test(() => {
     25    let c = new BroadcastChannel('');
     26    assert_throws_js(TypeError, () => c.postMessage());
     27  }, 'postMessage without parameters should throw');
     28 
     29 test(() => {
     30    let c = new BroadcastChannel('');
     31    c.postMessage(null);
     32  }, 'postMessage with null should not throw');
     33 
     34 test(() => {
     35    let c = new BroadcastChannel('');
     36    c.close();
     37  }, 'close should not throw');
     38 
     39 test(() => {
     40    let c = new BroadcastChannel('');
     41    c.close();
     42    c.close();
     43  }, 'close should not throw when called multiple times');
     44 
     45 test(() => {
     46    let c = new BroadcastChannel('');
     47    c.close();
     48    assert_throws_dom('InvalidStateError', () => c.postMessage(''));
     49  }, 'postMessage after close should throw');
     50 
     51 test(() => {
     52    let c = new BroadcastChannel('');
     53    assert_not_equals(c.onmessage, undefined);
     54  }, 'BroadcastChannel should have an onmessage event');
     55 
     56 test(() => {
     57    let c = new BroadcastChannel('');
     58    assert_throws_dom('DataCloneError', () => c.postMessage(Symbol()));
     59  }, 'postMessage should throw with uncloneable data');
     60 
     61 test(() => {
     62    let c = new BroadcastChannel('');
     63    c.close();
     64    assert_throws_dom('InvalidStateError', () => c.postMessage(Symbol()));
     65  }, 'postMessage should throw InvalidStateError after close, even with uncloneable data');