dom/tests/mochitest/bugs/worker_bug743615.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 importScripts('utils_bug743615.js');
     3 self.onmessage = function onMessage(evt) {
     4   // Check the pattern that was sent.
     5   var imageData = evt.data.imageData;
     6   var pattern = evt.data.pattern;
     7   var statusMessage = checkPattern(imageData, pattern)
     8                        ? 'PASS' : 'Got corrupt typed array in worker';
    10   // Check against the interface object.
    11   if (!(imageData instanceof ImageData))
    12     statusMessage += ", Bad interface object in worker";
    14   // Check the getters.
    15   if (imageData.width * imageData.height != imageData.data.length / 4) {
    16     statusMessage += ", Bad ImageData getters in worker: "
    17     statusMessage += [imageData.width, imageData.height].join(', ');
    18   }
    20   // Make sure that writing to .data is a no-op when not in strict mode.
    21   var origData = imageData.data;
    22   var threw = false;
    23   try {
    24     imageData.data = [];
    25     imageData.width = 2;
    26     imageData.height = 2;
    27   } catch(e) { threw = true; }
    28   if (threw || imageData.data !== origData)
    29     statusMessage = statusMessage + ", Should silently ignore sets";
    33   // Send back a new pattern.
    34   pattern = makePattern(imageData.data.length, 99, 2);
    35   setPattern(imageData, pattern);
    36   self.postMessage({ statusMessage: statusMessage, imageData: imageData,
    37                      pattern: pattern });
    38 }

mercurial