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.

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

mercurial