summaryrefslogtreecommitdiffstats
path: root/devtools/client/webide/test/test_manifestUpdate.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/webide/test/test_manifestUpdate.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/webide/test/test_manifestUpdate.html')
-rw-r--r--devtools/client/webide/test/test_manifestUpdate.html98
1 files changed, 98 insertions, 0 deletions
diff --git a/devtools/client/webide/test/test_manifestUpdate.html b/devtools/client/webide/test/test_manifestUpdate.html
new file mode 100644
index 000000000..66f9affd0
--- /dev/null
+++ b/devtools/client/webide/test/test_manifestUpdate.html
@@ -0,0 +1,98 @@
+<!DOCTYPE html>
+
+<html>
+
+ <head>
+ <meta charset="utf8">
+ <title></title>
+
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
+ <script type="application/javascript;version=1.8" src="head.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
+ </head>
+
+ <body>
+
+ <script type="application/javascript;version=1.8">
+ window.onload = function() {
+ SimpleTest.waitForExplicitFinish();
+
+ let {TextDecoder, OS} = Cu.import("resource://gre/modules/osfile.jsm", {});
+
+ Task.spawn(function* () {
+ let win = yield openWebIDE();
+ let winProject = getProjectWindow(win);
+ let AppManager = win.AppManager;
+
+ function isProjectMarkedAsValid() {
+ let details = win.frames[1];
+ return !details.document.body.classList.contains("error");
+ }
+
+ let packagedAppLocation = getTestFilePath("app");
+
+ let onValidated = waitForUpdate(win, "project-validated");
+ let onDetails = waitForUpdate(win, "details");
+ yield winProject.projectList.importPackagedApp(packagedAppLocation);
+ yield onValidated;
+ yield onDetails;
+
+ let project = win.AppManager.selectedProject;
+
+ ok("name" in project.manifest, "manifest includes name");
+ is(project.name, project.manifest.name, "Display name uses manifest name");
+ ok(isProjectMarkedAsValid(), "project is marked as valid");
+
+ // Change the name
+ let originalName = project.manifest.name;
+
+ project.manifest.name = "xxx";
+
+ // Write to disk
+ yield AppManager.writeManifest(project);
+
+ // Read file
+ let manifestPath = OS.Path.join(packagedAppLocation, "manifest.webapp");
+ let Decoder = new TextDecoder();
+ let data = yield OS.File.read(manifestPath);
+ data = new TextDecoder().decode(data);
+ let json = JSON.parse(data);
+ is(json.name, "xxx", "manifest written on disc");
+
+ // Make the manifest invalid on disk
+ delete json.name;
+ let Encoder = new TextEncoder();
+ data = Encoder.encode(JSON.stringify(json));
+ yield OS.File.writeAtomic(manifestPath, data , {tmpPath: manifestPath + ".tmp"});
+
+ // Trigger validation
+ yield AppManager.validateAndUpdateProject(AppManager.selectedProject);
+ yield nextTick();
+
+ ok(!("name" in project.manifest), "manifest has been updated");
+ is(project.name, "--", "Placeholder is used for display name");
+ ok(!isProjectMarkedAsValid(), "project is marked as invalid");
+
+ // Make the manifest valid on disk
+ project.manifest.name = originalName;
+ yield AppManager.writeManifest(project);
+
+ // Trigger validation
+ yield AppManager.validateAndUpdateProject(AppManager.selectedProject);
+ yield nextTick();
+
+ ok("name" in project.manifest, "manifest includes name");
+ is(project.name, originalName, "Display name uses original manifest name");
+ ok(isProjectMarkedAsValid(), "project is marked as valid");
+
+ yield closeWebIDE(win);
+
+ yield removeAllProjects();
+
+ SimpleTest.finish();
+ });
+ }
+ </script>
+ </body>
+</html>