summaryrefslogtreecommitdiffstats
path: root/dom/base/test/chrome/test_input_value_set_preserve_undo.xhtml
blob: 80465202ab99af7f722aab92651f3fc96eb3b780 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<window title="Bug 1676785"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<html:body>
  <xul:hbox>
    <html:input id="xul" />
  </xul:hbox>
  <html:div>
    <html:input id="non-xul" />
  </html:div>
</html:body>
<script class="testbody">
SimpleTest.waitForExplicitFinish();

function shouldPreserveHistory(input, preserve) {
  input.focus();
  input.value = "abc";
  input.value = "def";
  let ctrl = navigator.platform.indexOf("Mac") == 0 ? { metaKey: true } : { ctrlKey: true };
  synthesizeKey("z", ctrl);
  (preserve ? is : isnot)(input.value, "abc", `Expected ${input.id} to ${preserve ? "" : "not "}preserve undo history when setting .value`);
}

window.onload = function() {
  shouldPreserveHistory(document.getElementById("xul"), true);
  shouldPreserveHistory(document.getElementById("non-xul"), false);

  SimpleTest.finish();
}
</script>
</window>