summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit/test_cache2-32-clear-origin.js
blob: 52987a576f478b3a7100d43b84baa6947eaa80bf (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
"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,
                    {}
                  );

                  get_cache_service().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();
}