dom/workers/test/navigator_worker.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/workers/test/navigator_worker.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     1.4 +/**
     1.5 + * Any copyright is dedicated to the Public Domain.
     1.6 + * http://creativecommons.org/publicdomain/zero/1.0/
     1.7 + */
     1.8 +var supportedProps = [
     1.9 +  "appCodeName",
    1.10 +  "appName",
    1.11 +  "appVersion",
    1.12 +  "platform",
    1.13 +  "product",
    1.14 +  "taintEnabled",
    1.15 +  "userAgent",
    1.16 +  "onLine"
    1.17 +];
    1.18 +
    1.19 +for (var prop in navigator) {
    1.20 +  // Make sure the list is current!
    1.21 +  if (supportedProps.indexOf(prop) == -1) {
    1.22 +    throw "Navigator has the '" + prop + "' property that isn't in the list!";
    1.23 +  }
    1.24 +}
    1.25 +
    1.26 +var obj;
    1.27 +
    1.28 +for (var index = 0; index < supportedProps.length; index++) {
    1.29 +  var prop = supportedProps[index];
    1.30 +
    1.31 +  if (typeof navigator[prop] == "undefined") {
    1.32 +    throw "Navigator has no '" + prop + "' property!";
    1.33 +  }
    1.34 +
    1.35 +  obj = {
    1.36 +    name:  prop,
    1.37 +    value: prop === "taintEnabled" ? navigator[prop]() : navigator[prop]
    1.38 +  };
    1.39 +
    1.40 +  postMessage(JSON.stringify(obj));
    1.41 +}
    1.42 +
    1.43 +obj = {
    1.44 +  name: "testFinished"
    1.45 +};
    1.46 +
    1.47 +postMessage(JSON.stringify(obj));

mercurial