toolkit/components/social/test/browser/worker_xhr.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 // Used to test XHR in the worker.
     2 onconnect = function(e) {
     3   let port = e.ports[0];
     4   let req;
     5   try {
     6     req = new XMLHttpRequest();
     7   } catch(e) {
     8     port.postMessage({topic: "done", result: "FAILED to create XHR object, " + e.toString() });
     9   }
    10   if (req === undefined) { // until bug 756173 is fixed...
    11     port.postMessage({topic: "done", result: "FAILED to create XHR object"});
    12     return;
    13   }
    14   // The test that uses this worker MUST use the same origin to load the worker.
    15   // We fetch the test app manifest so we can check the data is what we expect.
    16   let url = "https://example.com/browser/toolkit/components/social/test/browser/data.json";
    17   req.open("GET", url, true);
    18   req.onreadystatechange = function() {
    19     if (req.readyState === 4) {
    20       let ok = req.status == 200 && req.responseText.length > 0;
    21       if (ok) {
    22         // check we actually got something sane...
    23         try {
    24           let data = JSON.parse(req.responseText);
    25           ok = "response" in data;
    26         } catch(e) {
    27           ok = e.toString();
    28         }
    29       }
    30       port.postMessage({topic: "done", result: ok ? "ok" : "bad response"});
    31     }
    32   }
    33   req.send(null);
    34 }

mercurial