Bug 719754 - rewrite events/test_docload.xul, r=marcoz
authorAlexander Surkov <surkov.alexander@gmail.com>
Fri, 27 Jan 2012 19:22:19 +0900
changeset 86777 afb95cbc720f8e80f02c72cfb4d620532333c459
parent 86776 0a548fed2a7ab4de392faede06b2244c579ef721
child 86778 7ab255f53568efa4dc84a34a1d2f7a18453ab315
child 86815 570dd369e02a7ad1cc48e738a052543458fdcf3b
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarcoz
bugs719754
milestone12.0a1
Bug 719754 - rewrite events/test_docload.xul, r=marcoz
accessible/tests/mochitest/Makefile.in
accessible/tests/mochitest/browser.js
accessible/tests/mochitest/events.js
accessible/tests/mochitest/events/Makefile.in
accessible/tests/mochitest/events/docload_wnd.xul
accessible/tests/mochitest/events/test_docload.xul
accessible/tests/mochitest/events/test_focus_browserui.xul
accessible/tests/mochitest/states.js
--- a/accessible/tests/mochitest/Makefile.in
+++ b/accessible/tests/mochitest/Makefile.in
@@ -70,16 +70,17 @@ include $(topsrcdir)/config/rules.mk
 		formimage.png \
 		letters.gif \
 		moz.png \
 		$(topsrcdir)/content/media/test/bug461281.ogg \
 		longdesc_src.html \
 		actions.js \
 		attributes.js \
 		autocomplete.js \
+		browser.js \
 		common.js \
 		events.js \
 		grid.js \
 		layout.js \
 		name.js \
 		relations.js \
 		role.js \
 		selectable.js \
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/browser.js
@@ -0,0 +1,96 @@
+/**
+ * Load the browser with the given url and then invokes the given function.
+ */
+function openBrowserWindow(aFunc, aURL)
+{
+  gBrowserContext.testFunc = aFunc;
+  gBrowserContext.startURL = aURL;
+
+  addLoadEvent(openBrowserWindowIntl);
+}
+
+/**
+ * Close the browser window.
+ */
+function closeBrowserWindow()
+{
+  gBrowserContext.browserWnd.close();
+}
+
+/**
+ * Return the browser window object.
+ */
+function browserWindow()
+{
+  return gBrowserContext.browserWnd;
+}
+
+/**
+ * Return tab browser object.
+ */
+function tabBrowser()
+{
+  return browserWindow().gBrowser;
+}
+
+/**
+ * Return browser element of the current tab.
+ */
+function currentBrowser()
+{
+  return tabBrowser().selectedBrowser;
+}
+
+/**
+ * Return DOM document of the current tab.
+ */
+function currentTabDocument()
+{
+  return currentBrowser().contentDocument;
+}
+
+/**
+ * Return input element of address bar.
+ */
+function urlbarInput()
+{
+  return browserWindow().document.getElementById("urlbar").inputField;
+}
+
+/**
+ * Return reload button.
+ */
+function reloadButton()
+{
+  return browserWindow().document.getElementById("urlbar-reload-button");
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// private section
+
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+var gBrowserContext =
+{
+  browserWnd: null,
+  testFunc: null,
+  startURL: ""
+};
+
+function openBrowserWindowIntl()
+{
+  gBrowserContext.browserWnd =
+    window.openDialog(Services.prefs.getCharPref("browser.chromeURL"),
+                      "_blank", "chrome,all,dialog=no",
+                      gBrowserContext.startURL);
+
+  addA11yLoadEvent(startBrowserTests, browserWindow());
+}
+
+function startBrowserTests()
+{
+  if (gBrowserContext.startURL) // wait for load
+    addA11yLoadEvent(gBrowserContext.testFunc, currentBrowser().contentWindow);
+  else
+    gBrowserContext.testFunc();
+}
--- a/accessible/tests/mochitest/events.js
+++ b/accessible/tests/mochitest/events.js
@@ -169,17 +169,17 @@ const DO_NOT_FINISH_TEST = 1;
  *     //
  *     //   * DOM node or accessible. *
  *     //   target getter: function() {},
  *     //
  *     //   * DOM event phase (false - bubbling). *
  *     //   phase getter: function() {},
  *     //
  *     //   * Callback, called to match handled event. *
- *     //   match : function() {},
+ *     //   match : function(aEvent) {},
  *     //
  *     //   * Callback, called when event is handled
  *     //   check: function(aEvent) {},
  *     //
  *     //   * Checker ID *
  *     //   getID: function() {},
  *     //
  *     //   * Event that don't have predefined order relative other events. *
@@ -1335,20 +1335,20 @@ function caretMoveChecker(aCaretOffset, 
        "Wrong caret offset for " + prettyName(aEvent.accessible));
   }
 }
 
 /**
  * State change checker.
  */
 function stateChangeChecker(aState, aIsExtraState, aIsEnabled,
-                            aTargetOrFunc, aTargetFuncArg)
+                            aTargetOrFunc, aTargetFuncArg, aIsAsync)
 {
   this.__proto__ = new invokerChecker(EVENT_STATE_CHANGE, aTargetOrFunc,
-                                      aTargetFuncArg);
+                                      aTargetFuncArg, aIsAsync);
 
   this.check = function stateChangeChecker_check(aEvent)
   {
     var event = null;
     try {
       var event = aEvent.QueryInterface(nsIAccessibleStateChangeEvent);
     } catch (e) {
       ok(false, "State change event was expected");
@@ -1365,16 +1365,32 @@ function stateChangeChecker(aState, aIsE
       "Wrong state of statechange event state");
 
     var state = aIsEnabled ? (aIsExtraState ? 0 : aState) : 0;
     var extraState = aIsEnabled ? (aIsExtraState ? aState : 0) : 0;
     var unxpdState = aIsEnabled ? 0 : (aIsExtraState ? 0 : aState);
     var unxpdExtraState = aIsEnabled ? 0 : (aIsExtraState ? aState : 0);
     testStates(event.accessible, state, extraState, unxpdState, unxpdExtraState);
   }
+
+  this.match = function stateChangeChecker_match(aEvent)
+  {
+    if (aEvent instanceof nsIAccessibleStateChangeEvent) {
+      var scEvent = aEvent.QueryInterface(nsIAccessibleStateChangeEvent);
+      return aEvent.accessible = this.target && scEvent.state == aState;
+    }
+    return false;
+  }
+}
+
+function asyncStateChangeChecker(aState, aIsExtraState, aIsEnabled,
+                                 aTargetOrFunc, aTargetFuncArg)
+{
+  this.__proto__ = new stateChangeChecker(aState, aIsExtraState, aIsEnabled,
+                                          aTargetOrFunc, aTargetFuncArg, true);
 }
 
 /**
  * Expanded state change checker.
  */
 function expandedStateChecker(aIsEnabled, aTargetOrFunc, aTargetFuncArg)
 {
   this.__proto__ = new invokerChecker(EVENT_STATE_CHANGE, aTargetOrFunc,
--- a/accessible/tests/mochitest/events/Makefile.in
+++ b/accessible/tests/mochitest/events/Makefile.in
@@ -40,32 +40,33 @@ DEPTH		= ../../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  = accessible/events
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-# test_docload.xul, docload_wnd.xul, test_scroll.xul disabled for misusing <tabbrowser> (bug 715857)
+# test_scroll.xul disabled for misusing <tabbrowser> (bug 715857)
 
 _TEST_FILES =\
 		docload_wnd.html \
 		focus.html \
 		scroll.html \
 		test_aria_alert.html \
 		test_aria_menu.html \
 		test_aria_objattr.html \
 		test_aria_statechange.html \
 		test_attrs.html \
 		test_caretmove.html \
 		test_caretmove.xul \
 		test_coalescence.html \
 		test_contextmenu.html \
 		test_docload.html \
+		test_docload.xul \
 		test_dragndrop.html \
 		test_flush.html \
 		test_focus_aria_activedescendant.html \
 		test_focus_autocomplete.xul \
 		test_focus_browserui.xul \
 		test_focus_contextmenu.xul \
 		test_focus_controls.html \
 		test_focus_dialog.html \
deleted file mode 100644
--- a/accessible/tests/mochitest/events/docload_wnd.xul
+++ /dev/null
@@ -1,275 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-
-<!-- Firefox tabbrowser -->
-<?xml-stylesheet href="chrome://browser/content/browser.css"
-                 type="text/css"?>
-<!-- SeaMonkey tabbrowser -->
-<?xml-stylesheet href="chrome://navigator/content/navigator.css"
-                 type="text/css"?>
-
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
-  <script type="application/javascript"
-          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
-
-  <script type="application/javascript">
-  <![CDATA[
-    ////////////////////////////////////////////////////////////////////////////
-    // SimpleTest stuffs
-
-    var gOpenerWnd = window.opener.wrappedJSObject;
-
-    function ok(aCond, aMsg) {
-      gOpenerWnd.SimpleTest.ok(aCond, aMsg);
-    }
-
-    function is(aExpected, aActual, aMsg) {
-      gOpenerWnd.SimpleTest.is(aExpected, aActual, aMsg);
-    }
-
-    function testStates(aAccOrElmOrID, aState, aExtraState, aAbsentState,
-                        aAbsentExtraState)
-    {
-      gOpenerWnd.testStates(aAccOrElmOrID, aState, aExtraState, aAbsentState,
-                            aAbsentExtraState);
-    }
-
-    var invokerChecker = gOpenerWnd.invokerChecker;
-    var asyncInvokerChecker = gOpenerWnd.asyncInvokerChecker;
-
-    const STATE_BUSY = gOpenerWnd.STATE_BUSY;
-    const EVENT_DOCUMENT_LOAD_COMPLETE =
-      gOpenerWnd.EVENT_DOCUMENT_LOAD_COMPLETE;
-    const EVENT_DOCUMENT_RELOAD = gOpenerWnd.EVENT_DOCUMENT_RELOAD;
-    const EVENT_DOCUMENT_LOAD_STOPPED =
-      gOpenerWnd.EVENT_DOCUMENT_LOAD_STOPPED;
-    const EVENT_REORDER = gOpenerWnd.EVENT_REORDER;
-    const EVENT_STATE_CHANGE = gOpenerWnd.EVENT_STATE_CHANGE;
-    const nsIAccessibleStateChangeEvent =
-      gOpenerWnd.nsIAccessibleStateChangeEvent;
-
-    //gOpenerWnd.gA11yEventDumpToConsole = true; // debug
-
-    ////////////////////////////////////////////////////////////////////////////
-    // Hacks to make xul:tabbrowser work.
-
-    var handleDroppedLink = null; // needed for tabbrowser usage
-
-    Components.utils.import("resource://gre/modules/Services.jsm");
-    var XULBrowserWindow = {
-      isBusy: false,
-      setOverLink: function (link, b) {
-      }
-    };
-
-    gFindBarInitialized = false;
-
-    ////////////////////////////////////////////////////////////////////////////
-    // Helpers.
-
-    function getContainer()
-    {
-      var idx = gTabBrowser.tabContainer.selectedIndex;
-      return gTabBrowser.getBrowserAtIndex(idx);
-    }
-
-    function getDocument()
-    {
-      return getContainer().contentDocument;
-    }
-
-    ////////////////////////////////////////////////////////////////////////////
-    // Invoker checkers.
-    function stateBusyChecker(aIsEnabled)
-    {
-      this.type = EVENT_STATE_CHANGE;
-      this.__defineGetter__("target", getDocument);
-
-      this.check = function stateBusyChecker_check(aEvent)
-      {
-        var event = null;
-        try {
-          var event = aEvent.QueryInterface(nsIAccessibleStateChangeEvent);
-        } catch (e) {
-          ok(false, "State change event was expected");
-        }
-
-        if (!event)
-          return;
-
-        is(event.state, STATE_BUSY, "Wrong state of statechange event.");
-        is(event.isEnabled(), aIsEnabled,
-           "Wrong value of state of statechange event");
-
-        testStates(event.accessible, (aIsEnabled ? STATE_BUSY : 0), 0,
-                   (aIsEnabled ? 0 : STATE_BUSY), 0);
-      }
-    }
-
-    function documentReloadChecker(aIsFromUserInput)
-    {
-      this.type = EVENT_DOCUMENT_RELOAD;
-      this.__defineGetter__("target", getDocument);
-
-      this.check = function documentReloadChecker_check(aEvent)
-      {
-        is(aEvent.isFromUserInput, aIsFromUserInput,
-           "Wrong value of isFromUserInput");
-      }
-    }
-
-    ////////////////////////////////////////////////////////////////////////////
-    // Invokers.
-
-    /**
-     * Load URI.
-     */
-    function loadURIInvoker(aURI)
-    {
-      this.invoke = function loadURIInvoker_invoke()
-      {
-        gTabBrowser.loadURI(aURI);
-      }
-
-      this.eventSeq = [
-        // We don't expect state change event for busy true since things happen
-        // quickly and it's coalesced.
-        new asyncInvokerChecker(EVENT_REORDER, getContainer),
-        new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, getDocument),
-        new stateBusyChecker(false)
-      ];
-
-      this.getID = function loadURIInvoker_getID()
-      {
-        return "load uri " + aURI;
-      }
-    }
-
-    /**
-     * Click reload page button.
-     */
-    function clickReloadBtnInvoker()
-    {
-      this.invoke = function clickReloadBtnInvoker_invoke()
-      {
-        synthesizeMouse(document.getElementById("reloadbtn"), 5, 5, {});
-      }
-
-      this.eventSeq = [
-        new documentReloadChecker(true),
-        new asyncInvokerChecker(EVENT_REORDER, getContainer),
-        new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, getDocument),
-        new stateBusyChecker(false)
-      ];
-
-      this.getID = function reloadInvoker_getID()
-      {
-        return "click reload page button";
-      }
-    }
-
-    /**
-     * Reload the page.
-     */
-    function reloadInvoker()
-    {
-      this.invoke = function reloadInvoker_invoke()
-      {
-        gTabBrowser.reload();
-      }
-
-      this.eventSeq = [
-        new documentReloadChecker(false),
-        new asyncInvokerChecker(EVENT_REORDER, getContainer),
-        new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, getDocument),
-        new stateBusyChecker(false)
-      ];
-
-      this.getID = function reloadInvoker_getID()
-      {
-        return "reload page";
-      }
-    }
-
-    /**
-     * Load wrong URI what results in error page loading.
-     */
-    function loadErrorPageInvoker(aURL, aURLDescr)
-    {
-      this.invoke = function loadErrorPageInvoker_invoke()
-      {
-        gTabBrowser.loadURI(aURL);
-      }
-
-      this.eventSeq = [
-        // We don't expect state change for busy true, load stopped events since
-        // things happen quickly and it's coalesced.
-        new asyncInvokerChecker(EVENT_REORDER, getContainer),
-        new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, getDocument),
-        new stateBusyChecker(false)
-      ];
-
-      this.getID = function loadErrorPageInvoker_getID()
-      {
-        return "load error page: '" + aURLDescr + "'";
-      }
-    }
-
-    ////////////////////////////////////////////////////////////////////////////
-    // Tests
-
-    var gQueue = null;
-
-    const Ci = Components.interfaces;
-
-    var gTabBrowser = null;
-    function doTest()
-    {
-      gTabBrowser = document.getElementById("content");
-
-      gQueue = new gOpenerWnd.eventQueue();
-      gQueue.push(new loadURIInvoker("about:"));
-      gQueue.push(new clickReloadBtnInvoker());
-      gQueue.push(new loadURIInvoker("about:mozilla"));
-      gQueue.push(new reloadInvoker());
-      gQueue.push(new loadErrorPageInvoker("www.wronguri.wronguri",
-                                           "Server not found"));
-      gQueue.push(new loadErrorPageInvoker("https://nocert.example.com:443",
-                                          "Untrusted Connection"));
-
-      gQueue.onFinish = function() { window.close(); }
-      gQueue.invoke();
-    }
-
-    gOpenerWnd.addA11yLoadEvent(doTest);
-  ]]>
-  </script>
-
-  <!-- Hack to make xul:tabbrowser work -->
-  <menubar>
-    <menu label="menu">
-      <menupopup>
-        <menuitem label="close window hook" id="menu_closeWindow"/>
-        <menuitem label="close hook" id="menu_close"/>
-      </menupopup>
-    </menu>
-  </menubar>
-
-  <button id="reloadbtn" label="reload page"
-          oncommand="gTabBrowser.reload();"/>
-
-  <toolbar>
-    <tabs id="tabbrowser-tabs" class="tabbrowser-tabs"
-          tabbrowser="content"
-          flex="1"
-          setfocus="false">
-      <tab class="tabbrowser-tab" selected="true"/>
-    </tabs>
-  </toolbar>
-  <tabbrowser id="content"
-              type="content-primary"
-              tabcontainer="tabbrowser-tabs"
-              flex="1"/>
-
-</window>
--- a/accessible/tests/mochitest/events/test_docload.xul
+++ b/accessible/tests/mochitest/events/test_docload.xul
@@ -14,30 +14,182 @@
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
+  <script type="application/javascript"
+          src="../browser.js"></script>
 
   <script type="application/javascript">
   <![CDATA[
-    // var gA11yEventDumpID = "eventdump"; // debug stuff
+    ////////////////////////////////////////////////////////////////////////////
+    // Invoker checkers.
+    function stateBusyChecker(aIsEnabled)
+    {
+      this.type = EVENT_STATE_CHANGE;
+      this.__defineGetter__("target", currentTabDocument);
+
+      this.check = function stateBusyChecker_check(aEvent)
+      {
+        var event = null;
+        try {
+          var event = aEvent.QueryInterface(nsIAccessibleStateChangeEvent);
+        } catch (e) {
+          ok(false, "State change event was expected");
+        }
+
+        if (!event)
+          return;
+
+        is(event.state, STATE_BUSY, "Wrong state of statechange event.");
+        is(event.isEnabled(), aIsEnabled,
+           "Wrong value of state of statechange event");
+
+        testStates(event.accessible, (aIsEnabled ? STATE_BUSY : 0), 0,
+                   (aIsEnabled ? 0 : STATE_BUSY), 0);
+      }
+    }
+
+    function documentReloadChecker(aIsFromUserInput)
+    {
+      this.type = EVENT_DOCUMENT_RELOAD;
+      this.__defineGetter__("target", currentTabDocument);
 
-    function doTest()
+      this.check = function documentReloadChecker_check(aEvent)
+      {
+        is(aEvent.isFromUserInput, aIsFromUserInput,
+           "Wrong value of isFromUserInput");
+      }
+    }
+
+    ////////////////////////////////////////////////////////////////////////////
+    // Invokers.
+
+    /**
+     * Load URI.
+     */
+    function loadURIInvoker(aURI)
+    {
+      this.invoke = function loadURIInvoker_invoke()
+      {
+        tabBrowser().loadURI(aURI);
+      }
+
+      this.eventSeq = [
+        // We don't expect state change event for busy true since things happen
+        // quickly and it's coalesced.
+        new asyncInvokerChecker(EVENT_REORDER, currentBrowser),
+        new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, currentTabDocument),
+        new stateBusyChecker(false)
+      ];
+
+      this.getID = function loadURIInvoker_getID()
+      {
+        return "load uri " + aURI;
+      }
+    }
+
+    /**
+     * Reload the page by F5 (isFromUserInput flag is true).
+     */
+    function userReloadInvoker()
     {
-      var w = window.openDialog("../events/docload_wnd.xul",
-                                "docload_test",
-                                "chrome,width=600,height=600");
+      this.invoke = function userReloadInvoker_invoke()
+      {
+        synthesizeKey("VK_F5", {}, browserWindow());
+      }
+
+      this.eventSeq = [
+        new documentReloadChecker(true),
+        new asyncInvokerChecker(EVENT_REORDER, currentBrowser),
+        new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, currentTabDocument),
+        new stateBusyChecker(false)
+      ];
+
+      this.getID = function userReloadInvoker_getID()
+      {
+        return "user reload page";
+      }
+    }
+
+    /**
+     * Reload the page (isFromUserInput flag is false).
+     */
+    function reloadInvoker()
+    {
+      this.invoke = function reloadInvoker_invoke()
+      {
+        tabBrowser().reload();
+      }
+
+      this.eventSeq = [
+        new documentReloadChecker(false),
+        new asyncInvokerChecker(EVENT_REORDER, currentBrowser),
+        new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, currentTabDocument),
+        new stateBusyChecker(false)
+      ];
+
+      this.getID = function reloadInvoker_getID()
+      {
+        return "reload page";
+      }
+    }
+
+    /**
+     * Load wrong URI what results in error page loading.
+     */
+    function loadErrorPageInvoker(aURL, aURLDescr)
+    {
+      this.invoke = function loadErrorPageInvoker_invoke()
+      {
+        tabBrowser().loadURI(aURL);
+      }
+
+      this.eventSeq = [
+        // We don't expect state change for busy true, load stopped events since
+        // things happen quickly and it's coalesced.
+        new asyncInvokerChecker(EVENT_REORDER, currentBrowser),
+        new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, currentTabDocument),
+        new stateBusyChecker(false)
+      ];
+
+      this.getID = function loadErrorPageInvoker_getID()
+      {
+        return "load error page: '" + aURLDescr + "'";
+      }
+    }
+
+    ////////////////////////////////////////////////////////////////////////////
+    // Tests
+
+    gA11yEventDumpToConsole = true; // debug
+
+    var gQueue = null;
+    function doTests()
+    {
+      gQueue = new eventQueue();
+      gQueue.push(new loadURIInvoker("about:"));
+      gQueue.push(new userReloadInvoker());
+      gQueue.push(new loadURIInvoker("about:mozilla"));
+      gQueue.push(new reloadInvoker());
+      gQueue.push(new loadErrorPageInvoker("www.wronguri.wronguri",
+                                           "Server not found"));
+      gQueue.push(new loadErrorPageInvoker("https://nocert.example.com:443",
+                                          "Untrusted Connection"));
+
+      gQueue.onFinish = function() { closeBrowserWindow(); }
+      gQueue.invoke();
     }
 
     SimpleTest.waitForExplicitFinish();
-    addLoadEvent(doTest);
+    openBrowserWindow(doTests);
   ]]>
   </script>
 
   <vbox flex="1" style="overflow: auto;">
   <body xmlns="http://www.w3.org/1999/xhtml">
     <a target="_blank"
        href="https://bugzilla.mozilla.org/show_bug.cgi?id=566103"
        title=" reorganize accessible document handling">
--- a/accessible/tests/mochitest/events/test_focus_browserui.xul
+++ b/accessible/tests/mochitest/events/test_focus_browserui.xul
@@ -14,50 +14,30 @@
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
+  <script type="application/javascript"
+          src="../browser.js"></script>
 
   <script type="application/javascript">
   <![CDATA[
-    Components.utils.import("resource://gre/modules/Services.jsm");
-
     ////////////////////////////////////////////////////////////////////////////
     // Helpers
 
-    function tabBrowser()
-    {
-      return gBrowserWnd.gBrowser;
-    }
-
-    function currentBrowser()
-    {
-      return tabBrowser().selectedBrowser;
-    }
-
-    function currentTabDocument()
-    {
-      return currentBrowser().contentDocument;
-    }
-
     function inputInDocument()
     {
       var tabdoc = currentTabDocument();
       return tabdoc.getElementById("input");
     }
 
-    function urlbarInput()
-    {
-      return gBrowserWnd.document.getElementById("urlbar").inputField;
-    }
-
     ////////////////////////////////////////////////////////////////////////////
     // Invokers
 
     function loadURI(aURI)
     {
       this.invoke = function loadURI_invoke()
       {
         tabBrowser().loadURI(aURI);
@@ -91,68 +71,53 @@
     }
 
     ////////////////////////////////////////////////////////////////////////////
     // Testing
 
     var gInputDocURI = "data:text/html,<html><input id='input'></html>";
     var gButtonDocURI = "data:text/html,<html><input id='input' type='button' value='button'></html>";
 
-    var gBrowserWnd = null;
-    function loadBrowser()
-    {
-      gBrowserWnd = window.openDialog(Services.prefs.getCharPref("browser.chromeURL"),
-                                      "_blank", "chrome,all,dialog=no", gInputDocURI);
-
-      addA11yLoadEvent(startTests, gBrowserWnd);
-    }
-
-    function startTests()
-    {
-      // Wait for tab load.
-      var browser = gBrowserWnd.gBrowser.selectedBrowser;
-      addA11yLoadEvent(doTests, browser.contentWindow);
-    }
-
     //gA11yEventDumpToConsole = true; // debug
 
     var gQueue = null;
     function doTests()
     {
       gQueue = new eventQueue();
 
       var tabDocument = currentTabDocument();
       var input = inputInDocument();
 
       // move focus to input inside tab document
-      gQueue.push(new synthTab(tabDocument, new focusChecker(input), gBrowserWnd));
+      gQueue.push(new synthTab(tabDocument, new focusChecker(input),
+                               browserWindow()));
 
       // open new url, focus moves to new document
       gQueue.push(new loadURI(gButtonDocURI));
 
       // back one page in history, moves moves on input of tab document
       gQueue.push(new goBack());
 
       // open new tab, focus moves to urlbar
-      gQueue.push(new synthKey(tabDocument, "t", { ctrlKey: true, window: gBrowserWnd },
+      gQueue.push(new synthKey(tabDocument, "t", { ctrlKey: true, window: browserWindow() },
                                new focusChecker(urlbarInput)));
 
       // close open tab, focus goes on input of tab document
-      gQueue.push(new synthKey(tabDocument, "w", { ctrlKey: true, window: gBrowserWnd },
+      gQueue.push(new synthKey(tabDocument, "w", { ctrlKey: true, window: browserWindow() },
                                new focusChecker(inputInDocument)));
 
       gQueue.onFinish = function()
       {
-        gBrowserWnd.close();
+        closeBrowserWindow();
       }
       gQueue.invoke();
     }
 
     SimpleTest.waitForExplicitFinish();
-    addLoadEvent(loadBrowser);
+    openBrowserWindow(doTests, gInputDocURI);
   ]]>
   </script>
 
   <vbox flex="1" style="overflow: auto;">
   <body xmlns="http://www.w3.org/1999/xhtml">
     <a target="_blank"
        href="https://bugzilla.mozilla.org/show_bug.cgi?id=644452"
        title="Focus not set when switching to cached document with back or forward if anything other than the document was last focused">
--- a/accessible/tests/mochitest/states.js
+++ b/accessible/tests/mochitest/states.js
@@ -32,19 +32,21 @@ const STATE_REQUIRED = nsIAccessibleStat
 const STATE_SELECTABLE = nsIAccessibleStates.STATE_SELECTABLE;
 const STATE_SELECTED = nsIAccessibleStates.STATE_SELECTED;
 const STATE_TRAVERSED = nsIAccessibleStates.STATE_TRAVERSED;
 const STATE_UNAVAILABLE = nsIAccessibleStates.STATE_UNAVAILABLE;
 
 const EXT_STATE_ACTIVE = nsIAccessibleStates.EXT_STATE_ACTIVE;
 const EXT_STATE_DEFUNCT = nsIAccessibleStates.EXT_STATE_DEFUNCT;
 const EXT_STATE_EDITABLE = nsIAccessibleStates.EXT_STATE_EDITABLE;
+const EXT_STATE_ENABLED = nsIAccessibleStates.EXT_STATE_ENABLED;
 const EXT_STATE_EXPANDABLE = nsIAccessibleStates.EXT_STATE_EXPANDABLE;
 const EXT_STATE_HORIZONTAL = nsIAccessibleStates.EXT_STATE_HORIZONTAL;
 const EXT_STATE_MULTI_LINE = nsIAccessibleStates.EXT_STATE_MULTI_LINE;
+const EXT_STATE_SENSITIVE = nsIAccessibleStates.EXT_STATE_SENSITIVE;
 const EXT_STATE_SINGLE_LINE = nsIAccessibleStates.EXT_STATE_SINGLE_LINE;
 const EXT_STATE_STALE = nsIAccessibleStates.EXT_STATE_STALE;
 const EXT_STATE_SUPPORTS_AUTOCOMPLETION =
   nsIAccessibleStates.EXT_STATE_SUPPORTS_AUTOCOMPLETION;
 const EXT_STATE_VERTICAL = nsIAccessibleStates.EXT_STATE_VERTICAL;
 
 const kOrdinalState = 0;
 const kExtraState = 1;