<?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 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        title="nsIAccessible XUL textboxes chrome tests">

  <script type="application/javascript" 
          src="chrome://mochikit/content/MochiKit/packed.js"></script>
  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />

  <script type="application/javascript"
          src="chrome://mochikit/content/a11y/accessible/common.js" />
  <script type="application/javascript"
          src="chrome://mochikit/content/a11y/accessible/testTextboxes.js" />

  <script type="application/javascript">
  <![CDATA[
    function doTest()
    {
      //////////////////////////////////////////////////////////////////////////
      // normal textbox without content and with no proper label
      testThis("unlabelled_Textbox", // ID
               "", // name
               "", // value
               "", // description
               role_entry, // role
               (state_focusable), // state
               (ext_state_editable), // extState
               (state_readonly), // absentState
               1, // numActions
               "activate",  // ActionName
               "Activate"); // ActionDescription

      //////////////////////////////////////////////////////////////////////////
      // normal textbox without content and with a proper label
      testThis("labelled_textbox", // ID
               "Second textbox:", // name
               "", // value
               "", // description
               role_entry, // role
               (state_focusable), // state
               (ext_state_editable), // extState
               (state_readonly), // absentState
               1, // numActions
               "activate",  // ActionName
               "Activate"); // ActionDescription

      //////////////////////////////////////////////////////////////////////////
      // normal textbox with content and with a proper label
      testThis("prefilled_textbox", // ID
               "Textbox with predefined value:", // name
               "I have some text", // value
               "", // description
               role_entry, // role
               (state_focusable), // state
               (ext_state_editable), // extState
               (state_readonly), // absentState
               1, // numActions
               "activate",  // ActionName
               "Activate"); // ActionDescription

      //////////////////////////////////////////////////////////////////////////
      // password textbox with a proper label
      testThis("password_textbox", // ID
               "Enter some password here:", // name
               "", // value
               "", // description
               role_password_text, // role
               (state_focusable), // state
               (ext_state_editable), // extState
               (state_readonly), // absentState
               1, // numActions
               "activate",  // ActionName
               "Activate"); // ActionDescription

      //////////////////////////////////////////////////////////////////////////
      // textarea without content and label
      testThis("unlabelled_Textarea", // ID
               "", // name
               "", // value
               "", // description
               role_entry, // role
               (state_focusable), // state
               (ext_state_editable | ext_state_multi_line), // extState
               (state_readonly), // absentState
               1, // numActions
               "activate",  // ActionName
               "Activate"); // ActionDescription

      //////////////////////////////////////////////////////////////////////////
      // textarea without content and with proper label
      testThis("labelled_textarea", // ID
               "Labelled textarea:", // name
               "", // value
               "", // description
               role_entry, // role
               (state_focusable), // state
               (ext_state_editable | ext_state_multi_line), // extState
               (state_readonly), // absentState
               1, // numActions
               "activate",  // ActionName
               "Activate"); // ActionDescription

      //////////////////////////////////////////////////////////////////////////
      // textarea with content and with proper label
      testThis("prefilled_textarea", // ID
               "Pre-filled textarea:", // name
               "I also have some text.", // value
               "", // description
               role_entry, // role
               (state_focusable), // state
               (ext_state_editable | ext_state_multi_line), // extState
               (state_readonly), // absentState
               1, // numActions
               "activate",  // ActionName
               "Activate"); // ActionDescription

      //////////////////////////////////////////////////////////////////////////
      // readonly textbox with content and with proper label
      testThis("readonly_textbox", // ID
               "The following is a read-only textbox:", // name
               "You cannot change me.", // value
               "", // description
               role_entry, // role
               (state_focusable | state_readonly), // state
               (0), // extState
               (0), // absentState
               1, // numActions
               "activate",  // ActionName
               "Activate"); // ActionDescription

      //////////////////////////////////////////////////////////////////////////
      // readonly textarea with content and with proper label
      testThis("readonly_textarea", // ID
               "This textarea is readonly, too:", // name
               "You cannot change me, either.", // value
               "", // description
               role_entry, // role
               (state_focusable | state_readonly), // state
               (ext_state_multi_line), // extState
               (0), // absentState
               1, // numActions
               "activate",  // ActionName
               "Activate"); // ActionDescription

      //////////////////////////////////////////////////////////////////////////
      // Search textbox without search button, searches as you type and filters
      // a separate control.
      testThis("search-box", // ID
               "Search History:", // name
               "", // value
               "", // description
               role_entry, // role
               (state_focusable), // state
               (ext_state_supports_autocompletion), // extState
               (0), // absentState
               1, // numActions
               "activate",  // ActionName
               "Activate"); // ActionDescription

      //////////////////////////////////////////////////////////////////////////
      // Search textbox with search button, does not support autoCompletion.
      testThis("searchfield", // ID
               "Search all add-ons", // name
               "", // value
               "", // description
               role_entry, // role
               (state_focusable), // state
               (0), // extState
               (0), // absentState
               1, // numActions
               "activate",  // ActionName
               "Activate"); // ActionDescription
      testStates("searchfield", getAccessible("searchfield"), 0, 0, 0,
                 ext_state_supports_autocompletion);
 
      SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addLoadEvent(doTest);
  ]]>
  </script>

  <body xmlns="http://www.w3.org/1999/xhtml">
    <a target="_blank"
       href="https://bugzilla.mozilla.org/show_bug.cgi?id=442648">
      Mozilla Bug 442648
    </a>
    <p id="display"></p>
    <div id="content" style="display: none"></div>
    <pre id="test">
    </pre>
  </body>

  <vbox>
    <hbox>
      <label value="Text before input without labelling it:"/>
      <textbox id="unlabelled_Textbox" size="50"/>
    </hbox>
    <hbox>
      <label control="labelled_textbox">Second textbox:</label>
      <textbox id="labelled_textbox"/>
    </hbox>
    <hbox>
      <label control="prefilled_textbox">Textbox with predefined value:</label>
      <textbox id="prefilled_textbox" value="I have some text" size="80"/>
    </hbox>
    <hbox>
      <label control="password_textbox">Enter some password here:</label>
      <textbox type="password" id="password_textbox"/>
    </hbox>
    <vbox>
      <label value="Textarea without label:"/>
      <textbox multiline="true" id="unlabelled_Textarea" cols="80" rows="5"/>
    </vbox>
    <vbox>
      <label control="labelled_textarea">Labelled textarea:</label>
      <textbox multiline="true" id="labelled_textarea" cols="80" rows="5"/>
    </vbox>
    <vbox>
      <label control="prefilled_textarea">Pre-filled textarea:</label>
      <textbox multiline="true" id="prefilled_textarea" cols="80" rows="5"
               value="I also have some text."/>
    </vbox>
    <hbox>
      <label control="readonly_textbox">The following is a read-only textbox:</label>
      <textbox readonly="true" id="readonly_textbox"
               value="You cannot change me."/>
    </hbox>
    <vbox>
      <label control="readonly_textarea">This textarea is readonly, too:</label>
      <textbox multiline="true" id="readonly_textarea" readonly="true" cols="80"
               rows="5" value="You cannot change me, either."/>
    </vbox>
    <hbox>
      <label value="Search History:" accesskey="S" 
             control="search-box"/>
	  <textbox id="search-box" flex="1" type="search"
	           results="historyTree"/>
    </hbox>
    <textbox id="searchfield" emptytext="Search all add-ons"
             type="search" searchbutton="true"/>
  </vbox>
</window>
