browser/devtools/app-manager/test/test_projects_store.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/app-manager/test/test_projects_store.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     1.4 +<!DOCTYPE html>
     1.5 +
     1.6 +<!--
     1.7 +Bug 907206 - data store for local apps 
     1.8 +-->
     1.9 +
    1.10 +<html>
    1.11 +
    1.12 +  <head>
    1.13 +    <meta charset="utf8">
    1.14 +    <title></title>
    1.15 +
    1.16 +    <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.17 +    <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
    1.18 +  </head>
    1.19 +
    1.20 +  <body>
    1.21 +
    1.22 +    <script type="application/javascript;version=1.8">
    1.23 +      const Cu = Components.utils;
    1.24 +
    1.25 +      window.onload = function() {
    1.26 +        SimpleTest.waitForExplicitFinish();
    1.27 +
    1.28 +        const {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
    1.29 +        const {require} = devtools;
    1.30 +
    1.31 +        const { AppProjects } = require("devtools/app-manager/app-projects");
    1.32 +
    1.33 +        function testHosted(projects) {
    1.34 +          let manifestURL = document.location.href.replace("test_projects_store.html", "hosted_app/webapp.manifest");
    1.35 +          AppProjects.addHosted(manifestURL)
    1.36 +            .then(function (app) {
    1.37 +              is(projects.length, 1,
    1.38 +                 "Hosted app has been added");
    1.39 +              is(projects[0], app);
    1.40 +              is(app.type, "hosted", "valid type");
    1.41 +              is(app.location, manifestURL, "valid location");
    1.42 +              is(AppProjects.get(manifestURL), app,
    1.43 +                 "get() returns the same app object");
    1.44 +              AppProjects.remove(manifestURL)
    1.45 +                .then(function () {
    1.46 +                  is(projects.length, 0,
    1.47 +                     "Hosted app has been removed");
    1.48 +                  SimpleTest.finish();
    1.49 +                });
    1.50 +            });
    1.51 +        }
    1.52 +
    1.53 +        AppProjects.once("ready", function (event, projects) {
    1.54 +          is(projects, AppProjects.store.object.projects,
    1.55 +             "The ready event data is the store projects list");
    1.56 +          testHosted(projects);
    1.57 +        });
    1.58 +
    1.59 +      }
    1.60 +
    1.61 +    </script>
    1.62 +  </body>
    1.63 +</html>

mercurial