summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit/test_cache2-32-clear-origin.js
blob: 8358f2f04521ea2d2f28e9246841156f36d0e613 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"use strict";

const URL = "http://example.net";
const URL2 = "http://foo.bar";

function run_test() {
  do_get_profile();

  asyncOpenCacheEntry(
    URL + "/a",
    "disk",
    Ci.nsICacheStorage.OPEN_NORMALLY,
    null,
    new OpenCallback(NEW, "e1m", "e1d", function (entry) {
      asyncOpenCacheEntry(
        URL + "/a",
        "disk",
        Ci.nsICacheStorage.OPEN_NORMALLY,
        null,
        new OpenCallback(NORMAL, "e1m", "e1d", function (entry) {
          asyncOpenCacheEntry(
            URL2 + "/a",
            "disk",
            Ci.nsICacheStorage.OPEN_NORMALLY,
            null,
            new OpenCallback(NEW, "f1m", "f1d", function (entry) {
              asyncOpenCacheEntry(
                URL2 + "/a",
                "disk",
                Ci.nsICacheStorage.OPEN_NORMALLY,
                null,
                new OpenCallback(NORMAL, "f1m", "f1d", function (entry) {
                  var url = Services.io.newURI(URL);
                  var principal =
                    Services.scriptSecurityManager.createContentPrincipal(
                      url,
                      {}
                    );

                  Services.cache2.clearOrigin(principal);

                  asyncOpenCacheEntry(
                    URL + "/a",
                    "disk",
                    Ci.nsICacheStorage.OPEN_NORMALLY,
                    null,
                    new OpenCallback(NEW, "e1m", "e1d", function (entry) {
                      asyncOpenCacheEntry(
                        URL2 + "/a",
                        "disk",
                        Ci.nsICacheStorage.OPEN_NORMALLY,
                        null,
                        new OpenCallback(NORMAL, "f1m", "f1d", function (
                          entry
                        ) {
                          finish_cache2_test();
                        })
                      );
                    })
                  );
                })
              );
            })
          );
        })
      );
    })
  );

  do_test_pending();
}