Backed out changeset 713114c0331a (bug 1938707) by developer request CLOSED TREE
[gecko.git] / js / xpconnect / tests / mochitest / test_json_parse_with_source_worker.html
blob75b26ba5fa80eb740bc7dddd8a331475bd9e0d28
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Test JSON.parse with source in workers</title>
6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
8 <script type="application/javascript">
9 "use strict";
11 SimpleTest.waitForExplicitFinish();
13 let worker = new Worker(URL.createObjectURL(new Blob([`
14 self.onmessage = function (event) {
15 let message = JSON.parse(event.data, (k,v,{source}) => { return { src: source, raw: JSON.rawJSON(source), val: v}});
16 message.isRaw = JSON.isRawJSON(message.raw)
17 postMessage(JSON.stringify(message)); // stringify to make sure it handles rawJSON correctly
19 `])));
21 worker.onmessage = event => {
22 let response = JSON.parse(event.data);
23 isDeeply(response, {src: "4.32", val: 4.32, raw: 4.32, isRaw: true});
24 SimpleTest.finish();
26 worker.postMessage("4.32");
27 </script>
28 </head>
30 </html>