dom/workers/test/navigator_worker.js

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 /**
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/publicdomain/zero/1.0/
     4  */
     5 var supportedProps = [
     6   "appCodeName",
     7   "appName",
     8   "appVersion",
     9   "platform",
    10   "product",
    11   "taintEnabled",
    12   "userAgent",
    13   "onLine"
    14 ];
    16 for (var prop in navigator) {
    17   // Make sure the list is current!
    18   if (supportedProps.indexOf(prop) == -1) {
    19     throw "Navigator has the '" + prop + "' property that isn't in the list!";
    20   }
    21 }
    23 var obj;
    25 for (var index = 0; index < supportedProps.length; index++) {
    26   var prop = supportedProps[index];
    28   if (typeof navigator[prop] == "undefined") {
    29     throw "Navigator has no '" + prop + "' property!";
    30   }
    32   obj = {
    33     name:  prop,
    34     value: prop === "taintEnabled" ? navigator[prop]() : navigator[prop]
    35   };
    37   postMessage(JSON.stringify(obj));
    38 }
    40 obj = {
    41   name: "testFinished"
    42 };
    44 postMessage(JSON.stringify(obj));

mercurial