зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1327674 - clear the html-editor undo/redo stack when switching to a new node;r=pbro
MozReview-Commit-ID: 7Sy4SDrPO2A --HG-- extra : rebase_source : 6f28bc28cb532a6703f38bc72ca07bf6a3f6ec1b
This commit is contained in:
Родитель
fc3f52d31f
Коммит
a6d0738aff
|
@ -134,6 +134,7 @@ skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32
|
|||
[browser_markup_html_edit_01.js]
|
||||
[browser_markup_html_edit_02.js]
|
||||
[browser_markup_html_edit_03.js]
|
||||
[browser_markup_html_edit_undo-redo.js]
|
||||
[browser_markup_image_tooltip.js]
|
||||
[browser_markup_image_tooltip_mutations.js]
|
||||
[browser_markup_keybindings_01.js]
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/* 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";
|
||||
|
||||
// Test that the undo/redo stack is correctly cleared when opening the HTML editor on a
|
||||
// new node. Bug 1327674.
|
||||
|
||||
const DIV1_HTML = "<div id=\"d1\">content1</div>";
|
||||
const DIV2_HTML = "<div id=\"d2\">content2</div>";
|
||||
const DIV2_HTML_UPDATED = "<div id=\"d2\">content2_updated</div>";
|
||||
|
||||
const TEST_URL = "data:text/html," +
|
||||
"<!DOCTYPE html>" +
|
||||
"<head><meta charset='utf-8' /></head>" +
|
||||
"<body>" +
|
||||
DIV1_HTML +
|
||||
DIV2_HTML +
|
||||
"</body>" +
|
||||
"</html>";
|
||||
|
||||
add_task(function* () {
|
||||
let {inspector} = yield openInspectorForURL(TEST_URL);
|
||||
|
||||
inspector.markup._frame.focus();
|
||||
|
||||
yield selectNode("#d1", inspector);
|
||||
|
||||
info("Open the HTML editor on node #d1");
|
||||
let onHtmlEditorCreated = once(inspector.markup, "begin-editing");
|
||||
EventUtils.sendKey("F2", inspector.markup._frame.contentWindow);
|
||||
yield onHtmlEditorCreated;
|
||||
|
||||
ok(inspector.markup.htmlEditor._visible, "HTML Editor is visible");
|
||||
is(inspector.markup.htmlEditor.editor.getText(), DIV1_HTML,
|
||||
"The editor content for d1 is correct.");
|
||||
|
||||
info("Hide the HTML editor for #d1");
|
||||
let onEditorHidden = once(inspector.markup.htmlEditor, "popuphidden");
|
||||
EventUtils.sendKey("ESCAPE", inspector.markup.htmlEditor.doc.defaultView);
|
||||
yield onEditorHidden;
|
||||
ok(!inspector.markup.htmlEditor._visible, "HTML Editor is not visible");
|
||||
|
||||
yield selectNode("#d2", inspector);
|
||||
|
||||
info("Open the HTML editor on node #d2");
|
||||
onHtmlEditorCreated = once(inspector.markup, "begin-editing");
|
||||
EventUtils.sendKey("F2", inspector.markup._frame.contentWindow);
|
||||
yield onHtmlEditorCreated;
|
||||
|
||||
ok(inspector.markup.htmlEditor._visible, "HTML Editor is visible");
|
||||
is(inspector.markup.htmlEditor.editor.getText(), DIV2_HTML,
|
||||
"The editor content for d2 is correct.");
|
||||
|
||||
inspector.markup.htmlEditor.editor.setText(DIV2_HTML_UPDATED);
|
||||
is(inspector.markup.htmlEditor.editor.getText(), DIV2_HTML_UPDATED,
|
||||
"The editor content for d2 is updated.");
|
||||
|
||||
inspector.markup.htmlEditor.editor.undo();
|
||||
is(inspector.markup.htmlEditor.editor.getText(), DIV2_HTML,
|
||||
"The editor content for d2 is reverted.");
|
||||
|
||||
inspector.markup.htmlEditor.editor.undo();
|
||||
is(inspector.markup.htmlEditor.editor.getText(), DIV2_HTML,
|
||||
"The editor content for d2 has not been set to content1.");
|
||||
|
||||
info("Hide the HTML editor for #d2");
|
||||
onEditorHidden = once(inspector.markup.htmlEditor, "popuphidden");
|
||||
EventUtils.sendKey("ESCAPE", inspector.markup.htmlEditor.doc.defaultView);
|
||||
yield onEditorHidden;
|
||||
ok(!inspector.markup.htmlEditor._visible, "HTML Editor is not visible");
|
||||
});
|
|
@ -127,6 +127,7 @@ HTMLEditor.prototype = {
|
|||
|
||||
this.editor.refresh();
|
||||
this.editor.focus();
|
||||
this.editor.clearHistory();
|
||||
|
||||
this.emit("popupshown");
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче