summaryrefslogtreecommitdiffstats
path: root/toolkit/components/thumbnails/test/browser_thumbnails_bg_redirect.js
blob: ae0096ff184b69e8883ca349f3ce77560ce161fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

add_task(async function thumbnails_bg_redirect() {
  let finalURL = "https://example.com/redirected";
  let originalURL = bgTestPageURL({ redirect: finalURL });

  ok(
    !thumbnailExists(originalURL),
    "Thumbnail file for original URL should not exist yet."
  );
  ok(
    !thumbnailExists(finalURL),
    "Thumbnail file for final URL should not exist yet."
  );

  let captureOriginalPromise = bgAddPageThumbObserver(originalURL);
  let captureFinalPromise = bgAddPageThumbObserver(finalURL);

  let [capturedURL] = await bgCapture(originalURL);
  is(capturedURL, originalURL, "Captured URL should be URL passed to capture");
  await captureOriginalPromise;
  await captureFinalPromise;
  ok(
    thumbnailExists(originalURL),
    "Thumbnail for original URL should be cached"
  );
  ok(thumbnailExists(finalURL), "Thumbnail for final URL should be cached");

  removeThumbnail(originalURL);
  removeThumbnail(finalURL);
});