summaryrefslogtreecommitdiffstats
path: root/dom/manifest/test/browser_ManifestObtainer_credentials.js
blob: 826ec24fc0169937d4900e13a6731500bbf6a11e (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
33
34
35
36
37
38
39
40
41
42
43
44
45
"use strict";

Services.prefs.setBoolPref("dom.manifest.enabled", true);

const { ManifestObtainer } = ChromeUtils.importESModule(
  "resource://gre/modules/ManifestObtainer.sys.mjs"
);

// Don't send cookies
add_task(async function () {
  const testPath = "/browser/dom/manifest/test/cookie_setter.html";
  const tabURL = `https://example.com${testPath}`;
  const browser = BrowserTestUtils.addTab(gBrowser, tabURL).linkedBrowser;
  await BrowserTestUtils.browserLoaded(browser);
  const { short_name } = await ManifestObtainer.browserObtainManifest(browser);
  is(short_name, "no cookie");
  const tab = gBrowser.getTabForBrowser(browser);
  gBrowser.removeTab(tab);
});

// Send cookies
add_task(async function () {
  const testPath =
    "/browser/dom/manifest/test/cookie_setter_with_credentials.html";
  const tabURL = `https://example.com${testPath}`;
  const browser = BrowserTestUtils.addTab(gBrowser, tabURL).linkedBrowser;
  await BrowserTestUtils.browserLoaded(browser);
  const { short_name } = await ManifestObtainer.browserObtainManifest(browser);
  is(short_name, "🍪");
  const tab = gBrowser.getTabForBrowser(browser);
  gBrowser.removeTab(tab);
});

// Cross origin - we go from example.com to example.org
add_task(async function () {
  const testPath =
    "/browser/dom/manifest/test/cookie_setter_with_credentials_cross_origin.html";
  const tabURL = `https://example.com${testPath}`;
  const browser = BrowserTestUtils.addTab(gBrowser, tabURL).linkedBrowser;
  await BrowserTestUtils.browserLoaded(browser);
  const { short_name } = await ManifestObtainer.browserObtainManifest(browser);
  is(short_name, "no cookie");
  const tab = gBrowser.getTabForBrowser(browser);
  gBrowser.removeTab(tab);
});