Ticket #13027: worker_test.html

File worker_test.html, 917 bytes (added by gacar, 5 years ago)
Line 
1<!DOCTYPE html>
2<html>
3<meta charset="utf-8">
4<head>
5        <title>WebWorker </title>
6</head>
7<body>
8<script type="text/javascript">
9
10        function compare_to_native_navigator(prop, worker_value){
11                if ((""+navigator[prop]) !== worker_value){ // postMessage casts the value to string before posting.
12                        add_to_list("FAIL - " + prop + ": <b>" + worker_value + "</b> != <b>" + navigator[prop] +"</b>");
13                }
14        }
15        function add_to_list(log_str){
16                var li = document.createElement("li");
17                li.innerHTML = log_str;
18                document.getElementById("comparison").appendChild(li);
19        }
20
21        var myWorker = new Worker("worker_test.js");
22
23        myWorker.onmessage = function (oEvent) {
24          var splitted_msg = oEvent.data.split("__sep__");
25          compare_to_native_navigator(splitted_msg[0], splitted_msg[1]);
26        };
27       
28</script>
29<p>If everything is ok (Navigator == WorkerNavigator) you shouldn't see anything below:</p>
30<ul id="comparison"></ul>
31
32</body>
33</html>
34