|
1 <!DOCTYPE html> |
|
2 |
|
3 <!-- |
|
4 Bug 907206 - data store for local apps |
|
5 --> |
|
6 |
|
7 <html> |
|
8 |
|
9 <head> |
|
10 <meta charset="utf8"> |
|
11 <title></title> |
|
12 |
|
13 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
14 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> |
|
15 </head> |
|
16 |
|
17 <body> |
|
18 |
|
19 <script type="application/javascript;version=1.8"> |
|
20 const Cu = Components.utils; |
|
21 |
|
22 window.onload = function() { |
|
23 SimpleTest.waitForExplicitFinish(); |
|
24 |
|
25 const {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); |
|
26 const {require} = devtools; |
|
27 |
|
28 const { AppProjects } = require("devtools/app-manager/app-projects"); |
|
29 |
|
30 function testHosted(projects) { |
|
31 let manifestURL = document.location.href.replace("test_projects_store.html", "hosted_app/webapp.manifest"); |
|
32 AppProjects.addHosted(manifestURL) |
|
33 .then(function (app) { |
|
34 is(projects.length, 1, |
|
35 "Hosted app has been added"); |
|
36 is(projects[0], app); |
|
37 is(app.type, "hosted", "valid type"); |
|
38 is(app.location, manifestURL, "valid location"); |
|
39 is(AppProjects.get(manifestURL), app, |
|
40 "get() returns the same app object"); |
|
41 AppProjects.remove(manifestURL) |
|
42 .then(function () { |
|
43 is(projects.length, 0, |
|
44 "Hosted app has been removed"); |
|
45 SimpleTest.finish(); |
|
46 }); |
|
47 }); |
|
48 } |
|
49 |
|
50 AppProjects.once("ready", function (event, projects) { |
|
51 is(projects, AppProjects.store.object.projects, |
|
52 "The ready event data is the store projects list"); |
|
53 testHosted(projects); |
|
54 }); |
|
55 |
|
56 } |
|
57 |
|
58 </script> |
|
59 </body> |
|
60 </html> |