summaryrefslogtreecommitdiffstats
path: root/dom/quota/test/xpcshell/test_specialOrigins.js
blob: d66700d359942850840ff7fe77dc05579a5a65e3 (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
46
47
48
49
50
51
52
53
54
55
/**
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

async function testSteps() {
  const origins = [
    {
      path: "storage/default/file+++UNIVERSAL_FILE_URI_ORIGIN",
      url: "file:///Test/test.html",
      persistence: "default",
    },
  ];

  info("Setting pref");

  SpecialPowers.setBoolPref("security.fileuri.strict_origin_policy", false);

  info("Initializing");

  let request = init();
  await requestFinished(request);

  info("Creating origin directories");

  for (let origin of origins) {
    let originDir = getRelativeFile(origin.path);
    originDir.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt("0755", 8));
  }

  info("Initializing temporary storage");

  request = initTemporaryStorage();
  await requestFinished(request);

  info("Initializing origin directories");

  for (let origin of origins) {
    let result;

    try {
      request = initTemporaryOrigin(
        origin.persistence,
        getPrincipal(origin.url)
      );
      result = await requestFinished(request);

      ok(true, "Should not have thrown");
    } catch (ex) {
      ok(false, "Should not have thrown");
    }

    ok(!result, "Origin directory wasn't created");
  }
}