summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/chrome/bug366992_window.xhtml
blob: 698d26b43ad1aa1ebb253c26214123919f2fa0a7 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?xml version="1.0"?>

<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>

<window id="366992 test"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        xmlns:html="http://www.w3.org/1999/xhtml"
        onload="onLoad();"
        width="600"
        height="600"
        title="366992 test">

  <commandset id="editMenuCommands">
    <commandset id="editMenuCommandSetAll" commandupdater="true" events="focus,select"
                oncommandupdate="goUpdateGlobalEditMenuItems()"/>
    <commandset id="editMenuCommandSetUndo" commandupdater="true" events="undo"
                oncommandupdate="goUpdateUndoEditMenuItems()"/>
    <commandset id="editMenuCommandSetPaste" commandupdater="true" events="clipboard"
                oncommandupdate="goUpdatePasteMenuItems()"/>
    <command id="cmd_undo" oncommand="goDoCommand('cmd_undo')"/>
    <command id="cmd_redo" oncommand="goDoCommand('cmd_redo')"/>
    <command id="cmd_cut" oncommand="goDoCommand('cmd_cut')"/>
    <command id="cmd_copy" oncommand="goDoCommand('cmd_copy')"/>
    <command id="cmd_paste" oncommand="goDoCommand('cmd_paste')"/>
    <command id="cmd_delete" oncommand="goDoCommand('cmd_delete')"/>
    <command id="cmd_selectAll" oncommand="goDoCommand('cmd_selectAll')"/>
    <command id="cmd_switchTextDirection" oncommand="goDoCommand('cmd_switchTextDirection');"/>
  </commandset>

  <script type="application/javascript"
          src="chrome://global/content/globalOverlay.js"/>
  <script type="application/javascript"
          src="chrome://global/content/editMenuOverlay.js"/>
  <script type="application/javascript"><![CDATA[
    // Without the fix for bug 366992, the delete command would be enabled
    // for the input even though the input's controller for this command
    // disables it.
    var gShouldNotBeReachedController = {
      supportsCommand(aCommand) {
        return aCommand == "cmd_delete";
      },
      isCommandEnabled(aCommand) {
        return aCommand == "cmd_delete";
      },
      doCommand(aCommand) { }
    }

    function ok(condition, message) {
      window.arguments[0].SimpleTest.ok(condition, message);
    }
    function finish() {
      window.controllers.removeController(gShouldNotBeReachedController);
      window.close();
      window.arguments[0].SimpleTest.finish();
    }

    function onLoad() {
      document.getElementById("input").focus();
      var deleteDisabled = document.getElementById("cmd_delete")
                                   .getAttribute("disabled") == "true";
      ok(deleteDisabled,
         "cmd_delete should be disabled when the empty input is focused");
      finish();
    }

    window.controllers.appendController(gShouldNotBeReachedController);
  ]]></script>

  <html:input id="input"/>
</window>