tor-browser

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

structured-clone-message.html (2143B)


      1 <!doctype html>
      2 <title>structured clone of message</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <div id="log"></div>
      6 <script>
      7 var wrapper_test = async_test();
      8 var tests = [
      9      {test:async_test('undefined'), check:function(e) { assert_equals(e.data, undefined); }},
     10      {test:async_test('null'), check:function(e) { assert_equals(e.data, null); }},
     11      {test:async_test('false'), check:function(e) { assert_false(e.data); }},
     12      {test:async_test('true'), check:function(e) { assert_true(e.data); }},
     13      {test:async_test('1'), check:function(e) { assert_equals(e.data, 1); }},
     14      {test:async_test('NaN'), check:function(e) { assert_equals(e.data, NaN); }},
     15      {test:async_test('Infinity'), check:function(e) { assert_equals(e.data, Infinity); }},
     16      {test:async_test('string'), check:function(e) { assert_equals(e.data, 'foo'); }},
     17      {test:async_test('date'), check:function(e) { assert_equals(e.data instanceof Date, true); }},
     18      {test:async_test('regexp'), check:function(e) { assert_equals('' + e.data, '/foo/'); assert_equals(e.data instanceof RegExp, true, 'e.data instanceof RegExp'); }},
     19      {test:async_test('self'), check:function(e) { assert_equals(e.data, null); }},
     20      {test:async_test('array'), check:function(e) { assert_array_equals(e.data, [undefined, null, false, true, 1, NaN, Infinity, 'foo', null, null]); }},
     21      {test:async_test('object'), check:function(e) { assert_object_equals(e.data, {a:undefined, b:null, c:false, d:true, e:1, f:NaN, g:Infinity, h:'foo', k:null, n:null}); }},
     22      {test:async_test('error'), check:function(e) { assert_equals(e.data, null, 'new Error()'); }},
     23      {test:wrapper_test, check:function(e) { assert_unreached(); }}
     24 ];
     25 // make wrapper_test pass after 500ms
     26 setTimeout(tests[tests.length-1].test.step_func(function() {
     27  this.done();
     28 }), 500);
     29 
     30 wrapper_test.step(function() {
     31  var worker = new Worker('structured-clone-message.js');
     32  var i = 0;
     33  worker.onmessage = function(e) {
     34    tests[i].test.step(function() { tests[i].check(e); this.done(); });
     35    i++;
     36  };
     37 });
     38 </script>