toolkit/components/thumbnails/test/browser_thumbnails_bg_no_cookies_sent.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/thumbnails/test/browser_thumbnails_bg_no_cookies_sent.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,38 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +function runTests() {
     1.8 +  // Visit the test page in the browser and tell it to set a cookie.
     1.9 +  let url = bgTestPageURL({ setGreenCookie: true });
    1.10 +  let tab = gBrowser.loadOneTab(url, { inBackground: false });
    1.11 +  let browser = tab.linkedBrowser;
    1.12 +  yield whenLoaded(browser);
    1.13 +
    1.14 +  // The root element of the page shouldn't be green yet.
    1.15 +  let greenStr = "rgb(0, 255, 0)";
    1.16 +  isnot(browser.contentDocument.documentElement.style.backgroundColor,
    1.17 +        greenStr,
    1.18 +        "The page shouldn't be green yet.");
    1.19 +
    1.20 +  // Cookie should be set now.  Reload the page to verify.  Its root element
    1.21 +  // will be green if the cookie's set.
    1.22 +  browser.reload();
    1.23 +  yield whenLoaded(browser);
    1.24 +  is(browser.contentDocument.documentElement.style.backgroundColor,
    1.25 +     greenStr,
    1.26 +     "The page should be green now.");
    1.27 +
    1.28 +  // Capture the page.  Get the image data of the capture and verify it's not
    1.29 +  // green.  (Checking only the first pixel suffices.)
    1.30 +  yield bgCapture(url);
    1.31 +  ok(thumbnailExists(url), "Thumbnail file should exist after capture.");
    1.32 +
    1.33 +  retrieveImageDataForURL(url, function ([r, g, b]) {
    1.34 +    isnot([r, g, b].toString(), [0, 255, 0].toString(),
    1.35 +          "The captured page should not be green.");
    1.36 +    gBrowser.removeTab(tab);
    1.37 +    removeThumbnail(url);
    1.38 +    next();
    1.39 +  });
    1.40 +  yield true;
    1.41 +}

mercurial