summaryrefslogtreecommitdiffstats
path: root/devtools/client/projecteditor/test/browser_projecteditor_editing_01.js
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/projecteditor/test/browser_projecteditor_editing_01.js
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/projecteditor/test/browser_projecteditor_editing_01.js')
-rw-r--r--devtools/client/projecteditor/test/browser_projecteditor_editing_01.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/devtools/client/projecteditor/test/browser_projecteditor_editing_01.js b/devtools/client/projecteditor/test/browser_projecteditor_editing_01.js
new file mode 100644
index 000000000..c7ff1c0be
--- /dev/null
+++ b/devtools/client/projecteditor/test/browser_projecteditor_editing_01.js
@@ -0,0 +1,70 @@
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+//
+// Whitelisting this test.
+// As part of bug 1077403, the leaking uncaught rejection should be fixed.
+//
+thisTestLeaksUncaughtRejectionsAndShouldBeFixed("destroy");
+
+loadHelperScript("helper_edits.js");
+
+// Test ProjectEditor basic functionality
+add_task(function* () {
+ let projecteditor = yield addProjectEditorTabForTempDirectory();
+ let TEMP_PATH = projecteditor.project.allPaths()[0];
+
+ is(getTempFile("").path, TEMP_PATH, "Temp path is set correctly.");
+
+ ok(projecteditor.currentEditor, "There is an editor for projecteditor");
+ let resources = projecteditor.project.allResources();
+
+ for (let data of helperEditData) {
+ info("Processing " + data.path);
+ let resource = resources.filter(r=>r.basename === data.basename)[0];
+ yield selectFile(projecteditor, resource);
+ yield testEditFile(projecteditor, getTempFile(data.path).path, data.newContent);
+ }
+});
+
+function* testEditFile(projecteditor, filePath, newData) {
+ info("Testing file editing for: " + filePath);
+
+ let initialData = yield getFileData(filePath);
+ let editor = projecteditor.currentEditor;
+ let resource = projecteditor.resourceFor(editor);
+ let viewContainer = projecteditor.projectTree.getViewContainer(resource);
+ let originalTreeLabel = viewContainer.label.textContent;
+
+ is(resource.path, filePath, "Resource path is set correctly");
+ is(editor.editor.getText(), initialData, "Editor is loaded with correct file contents");
+
+ info("Setting text in the editor and doing checks before saving");
+
+ editor.editor.undo();
+ editor.editor.undo();
+ is(editor.editor.getText(), initialData, "Editor is still loaded with correct contents after undo");
+
+ editor.editor.setText(newData);
+ is(editor.editor.getText(), newData, "Editor has been filled with new data");
+ is(viewContainer.label.textContent, "*" + originalTreeLabel, "Label is marked as changed");
+
+ info("Saving the editor and checking to make sure the file gets saved on disk");
+
+ editor.save(resource);
+
+ let savedResource = yield onceEditorSave(projecteditor);
+
+ is(viewContainer.label.textContent, originalTreeLabel, "Label is unmarked as changed");
+ is(savedResource.path, filePath, "The saved resouce path matches the original file path");
+ is(savedResource, resource, "The saved resource is the same as the original resource");
+
+ let savedData = yield getFileData(filePath);
+ is(savedData, newData, "Data has been correctly saved to disk");
+
+ info("Finished checking saving for " + filePath);
+
+}