summaryrefslogtreecommitdiff
path: root/browser/devtools/sourceeditor/test/browser_bug684546_reset_undo.js
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2014-05-21 11:38:25 +0200
committerwolfbeast <mcwerewolf@gmail.com>2014-05-21 11:38:25 +0200
commitd25ba7d760b017b038e5aa6c0a605b4a330eb68d (patch)
tree16ec27edc7d5f83986f16236d3a36a2682a0f37e /browser/devtools/sourceeditor/test/browser_bug684546_reset_undo.js
parenta942906574671868daf122284a9c4689e6924f74 (diff)
downloadpalemoon-gre-d25ba7d760b017b038e5aa6c0a605b4a330eb68d.tar.gz
Recommit working copy to repo with proper line endings.
Diffstat (limited to 'browser/devtools/sourceeditor/test/browser_bug684546_reset_undo.js')
-rw-r--r--browser/devtools/sourceeditor/test/browser_bug684546_reset_undo.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/browser/devtools/sourceeditor/test/browser_bug684546_reset_undo.js b/browser/devtools/sourceeditor/test/browser_bug684546_reset_undo.js
new file mode 100644
index 000000000..4fbb01bde
--- /dev/null
+++ b/browser/devtools/sourceeditor/test/browser_bug684546_reset_undo.js
@@ -0,0 +1,72 @@
+/* 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";
+
+let tempScope = {};
+Cu.import("resource:///modules/source-editor.jsm", tempScope);
+let SourceEditor = tempScope.SourceEditor;
+
+let testWin;
+let editor;
+
+function test()
+{
+ waitForExplicitFinish();
+
+ const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
+ "<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
+ " title='test for bug 684546 - reset undo' width='300' height='500'>" +
+ "<box flex='1'/></window>";
+ const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
+
+ testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
+ testWin.addEventListener("load", function onWindowLoad() {
+ testWin.removeEventListener("load", onWindowLoad, false);
+ waitForFocus(initEditor, testWin);
+ }, false);
+}
+
+function initEditor()
+{
+ let box = testWin.document.querySelector("box");
+
+ editor = new SourceEditor();
+ editor.init(box, {}, editorLoaded);
+}
+
+function editorLoaded()
+{
+ editor.setText("First");
+ editor.setText("Second", 5);
+ is(editor.getText(), "FirstSecond", "text set correctly.");
+ editor.undo();
+ is(editor.getText(), "First", "undo works.");
+ editor.redo();
+ is(editor.getText(), "FirstSecond", "redo works.");
+ editor.resetUndo();
+ ok(!editor.canUndo(), "canUndo() is correct");
+ ok(!editor.canRedo(), "canRedo() is correct");
+ editor.undo();
+ is(editor.getText(), "FirstSecond", "reset undo works correctly");
+ editor.setText("Third", 11);
+ is(editor.getText(), "FirstSecondThird", "text set correctly");
+ editor.undo();
+ is(editor.getText(), "FirstSecond", "undo works after reset");
+ editor.redo();
+ is(editor.getText(), "FirstSecondThird", "redo works after reset");
+ editor.resetUndo();
+ ok(!editor.canUndo(), "canUndo() is correct (again)");
+ ok(!editor.canRedo(), "canRedo() is correct (again)");
+ editor.undo();
+ is(editor.getText(), "FirstSecondThird", "reset undo still works correctly");
+
+ finish();
+}
+
+registerCleanupFunction(function() {
+ editor.destroy();
+ testWin.close();
+ testWin = editor = null;
+});