Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test JSON.parse with source in workers</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let worker = new Worker(URL.createObjectURL(new Blob([`
self.onmessage = function (event) {
let message = JSON.parse(event.data, (k,v,{source}) => { return { src: source, raw: JSON.rawJSON(source), val: v}});
message.isRaw = JSON.isRawJSON(message.raw)
postMessage(JSON.stringify(message)); // stringify to make sure it handles rawJSON correctly
}
`])));
worker.onmessage = event => {
let response = JSON.parse(event.data);
isDeeply(response, {src: "4.32", val: 4.32, raw: 4.32, isRaw: true});
SimpleTest.finish();
};
worker.postMessage("4.32");
</script>
</head>
</html>