diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/projecteditor/test/browser_projecteditor_external_change.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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_external_change.js')
-rw-r--r-- | devtools/client/projecteditor/test/browser_projecteditor_external_change.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/devtools/client/projecteditor/test/browser_projecteditor_external_change.js b/devtools/client/projecteditor/test/browser_projecteditor_external_change.js new file mode 100644 index 000000000..12d90a869 --- /dev/null +++ b/devtools/client/projecteditor/test/browser_projecteditor_external_change.js @@ -0,0 +1,84 @@ +/* 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"; + +loadHelperScript("helper_edits.js"); + +// Test ProjectEditor reaction to external changes (made outside of the) +// editor. +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 testChangeFileExternally(projecteditor, getTempFile(data.path).path, data.newContent); + yield testChangeUnsavedFileExternally(projecteditor, getTempFile(data.path).path, data.newContent + "[changed]"); + } +}); + +function* testChangeUnsavedFileExternally(projecteditor, filePath, newData) { + info("Testing file external changes for: " + filePath); + + let editor = projecteditor.currentEditor; + let resource = projecteditor.resourceFor(editor); + let initialData = yield getFileData(filePath); + + is(resource.path, filePath, "Resource path is set correctly"); + is(editor.editor.getText(), initialData, "Editor is loaded with correct file contents"); + + info("Editing but not saving file in project editor"); + ok(editor.isClean(), "Editor is clean"); + editor.editor.setText("foobar"); + ok(!editor.isClean(), "Editor is dirty"); + + info("Editor has been selected, writing to file externally"); + yield writeToFile(resource.path, newData); + + info("Selecting another resource, then reselecting this one"); + projecteditor.projectTree.selectResource(resource.store.root); + yield onceEditorActivated(projecteditor); + projecteditor.projectTree.selectResource(resource); + yield onceEditorActivated(projecteditor); + + editor = projecteditor.currentEditor; + info("Checking to make sure the editor is now populated correctly"); + is(editor.editor.getText(), "foobar", "Editor has not been updated with new file contents"); + + info("Finished checking saving for " + filePath); +} + +function* testChangeFileExternally(projecteditor, filePath, newData) { + info("Testing file external changes for: " + filePath); + + let editor = projecteditor.currentEditor; + let resource = projecteditor.resourceFor(editor); + let initialData = yield getFileData(filePath); + + is(resource.path, filePath, "Resource path is set correctly"); + is(editor.editor.getText(), initialData, "Editor is loaded with correct file contents"); + + info("Editor has been selected, writing to file externally"); + yield writeToFile(resource.path, newData); + + info("Selecting another resource, then reselecting this one"); + projecteditor.projectTree.selectResource(resource.store.root); + yield onceEditorActivated(projecteditor); + projecteditor.projectTree.selectResource(resource); + yield onceEditorActivated(projecteditor); + + editor = projecteditor.currentEditor; + info("Checking to make sure the editor is now populated correctly"); + is(editor.editor.getText(), newData, "Editor has been updated with correct file contents"); + + info("Finished checking saving for " + filePath); +} |