Bug 719754 - rewrite events/test_scroll.xul, patch=marcoz, surkov, r=marcoz
authorAlexander Surkov <surkov.alexander@gmail.com>
Wed, 01 Feb 2012 14:17:42 +0900
changeset 89216 a5617ff71043a645362b2d5c1f20bcea842c21b3
parent 89215 88ac74cd45ad153d76a13510eefaf3eb3c2ab1b1
child 89217 c2832d09301f2a778171747e7fa789c731f688b3
push id136
push userlsblakk@mozilla.com
push dateFri, 01 Jun 2012 02:39:32 +0000
treeherdermozilla-release@7ebf7352c959 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarcoz
bugs719754
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 719754 - rewrite events/test_scroll.xul, patch=marcoz, surkov, r=marcoz
accessible/tests/mochitest/actions/test_anchors.html
accessible/tests/mochitest/browser.js
accessible/tests/mochitest/events/Makefile.in
accessible/tests/mochitest/events/test_scroll.xul
--- a/accessible/tests/mochitest/actions/test_anchors.html
+++ b/accessible/tests/mochitest/actions/test_anchors.html
@@ -44,16 +44,25 @@
           ID: "anchor1",
           actionName: "jump",
           actionIndex: 0,
           events: CLICK_EVENTS,
           eventSeq: [
             new scrollingChecker(getAccessible("bottom1"))
           ]
         },
+        { // jump again (test for bug 437607)
+          ID: "anchor1",
+          actionName: "jump",
+          actionIndex: 0,
+          events: CLICK_EVENTS,
+          eventSeq: [
+            new scrollingChecker(getAccessible("bottom1"))
+          ]
+        },
         {
           ID: "anchor2",
           actionName: "jump",
           actionIndex: 0,
           events: CLICK_EVENTS,
           eventSeq: [
             new scrollingChecker(getAccessible("bottom2"))
           ]
--- a/accessible/tests/mochitest/browser.js
+++ b/accessible/tests/mochitest/browser.js
@@ -45,16 +45,32 @@ function currentBrowser()
  * Return DOM document of the current tab.
  */
 function currentTabDocument()
 {
   return currentBrowser().contentDocument;
 }
 
 /**
+ * Return browser element of the tab at the given index.
+ */
+function browserAt(aIndex)
+{
+  return tabBrowser().getBrowserAtIndex(aIndex);
+}
+
+/**
+ * Return DOM document of the tab at the given index.
+ */
+function tabDocumentAt(aIndex)
+{
+  return browserAt(aIndex).contentDocument;
+}
+
+/**
  * Return input element of address bar.
  */
 function urlbarInput()
 {
   return browserWindow().document.getElementById("urlbar").inputField;
 }
 
 /**
--- a/accessible/tests/mochitest/events/Makefile.in
+++ b/accessible/tests/mochitest/events/Makefile.in
@@ -77,16 +77,17 @@ include $(topsrcdir)/config/rules.mk
 		test_focus_menu.xul \
 		test_focus_name.html \
 		test_focus_selects.html \
 		test_focus_tabbox.xul \
 		test_focus_tree.xul \
 		test_menu.xul \
 		test_mutation.html \
 		test_mutation.xhtml \
+		test_scroll.xul \
 		test_selection_aria.html \
 		test_selection.html \
 		test_selection.xul \
 		test_statechange.html \
 		test_text_alg.html \
 		test_text.html \
 		test_textattrchange.html \
 		test_tree.xul \
--- a/accessible/tests/mochitest/events/test_scroll.xul
+++ b/accessible/tests/mochitest/events/test_scroll.xul
@@ -1,125 +1,97 @@
 <?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"?>
-
 <?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">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
-          src="chrome://browser/content/utilityOverlay.js"/>
+          src="chrome://mochikit/content/chrome-harness.js"/>
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
           src="../states.js" />
   <script type="application/javascript"
           src="../events.js" />
-
   <script type="application/javascript"
-          src="chrome://mochikit/content/chrome-harness.js"/>
+          src="../browser.js"></script>
 
   <script type="application/javascript">
   <![CDATA[
 
     ////////////////////////////////////////////////////////////////////////////
-    // Hacks to make xul:tabbrowser work
-
-    const Ci = Components.interfaces;
-    const CC = Components.classes;
-
-    Components.utils.import("resource://gre/modules/Services.jsm");
-
-    var handleDroppedLink = null;
-
-    var XULBrowserWindow = {
-      isBusy: false,
-      setOverLink: function (link, b) {
-      }
-    };
-
-    var gURLBar = {
-      focused: false
-    };
-
-    var gFindBarInitialized = false;
-
-    function goSetCommandEnabled() {}
-
-    ////////////////////////////////////////////////////////////////////////////
     // Tests
 
-    function getTabDocument()
+    function getAnchorJumpInTabDocument(aTabIdx)
     {
-      return getNode("tabBrowser").selectedBrowser.contentDocument;
-    }
-
-    function getAnchorJumpInTabDocument()
-    {
-      return getTabDocument().querySelector("a[name='link1']");
+      var tabDoc = aTabIdx ? tabDocumentAt(aTabIdx) : currentTabDocument();
+      return tabDoc.querySelector("a[name='link1']");
     }
 
-    function loadTab(aTabBrowserID, aURL)
+    function loadTab(aURL)
     {
-      function loadTabChecker()
-      {
-        this.type = EVENT_REORDER;
-        this.match = function loadTabChecker_match(aEvent)
-        {
-          var target = aEvent.accessible;
-          if (target.role == ROLE_INTERNAL_FRAME &&
-              target.parent.parent == getAccessible(getNode(aTabBrowserID).mTabBox.tabpanels)) {
-            return true;
-          }
-          return false;
-        }
-      }
-
-      this.eventSeq = [ new loadTabChecker() ];
+      this.eventSeq = [
+        new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, currentTabDocument),
+        new invokerChecker(EVENT_SCROLLING_START, getAnchorJumpInTabDocument)
+      ];
 
       this.invoke = function loadTab_invoke()
       {
-        getNode(aTabBrowserID).loadURI(aURL);
+        tabBrowser().loadURI(aURL);
       }
 
       this.getID = function loadTab_getID()
       {
-        return "load tab " + aURL + " for " + prettyName(aTabBrowserID);
+        return "load tab: " + aURL;
       }
     }
 
-    function advanceFocusIntoTab(aTabBrowserID)
+    function loadTabInBackground(aURL)
     {
       this.eventSeq = [
-        new focusChecker(getTabDocument),
+        new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, tabDocumentAt, 1)
+      ];
+
+      this.unexpectedEventSeq = [
+        new invokerChecker(EVENT_SCROLLING_START, getAnchorJumpInTabDocument, 1)
+      ];
+
+      this.invoke = function loadTabInBackground_invoke()
+      {
+        tabBrowser().loadOneTab(aURL, null, "", null, true);
+      }
+
+      this.getID = function loadTabInBackground_getID()
+      {
+        return "load tab in background: " + aURL;
+      }
+    }
+
+    function switchToBackgroundTab()
+    {
+      this.eventSeq = [
         new invokerChecker(EVENT_SCROLLING_START, getAnchorJumpInTabDocument)
       ];
 
-      this.invoke = function advanceFocusIntoTab_invoke()
+      this.invoke = function switchToBackgroundTab_invoke()
       {
-        var tabDoc = getAccessible(getTabDocument());
-        tabDoc.takeFocus();
+        tabBrowser().selectTabAtIndex(1);
       }
 
-      this.getID = function advanceFocusIntoTab_getID()
+      this.getID = function switchToBackgroundTab_getID()
       {
-        return "advance focus into loaded tab";
+        return "switch to background tab";
       }
     }
 
     //gA11yEventDumpToConsole = true; // debug stuff
 
     var gQueue = null;
     function doTest()
     {
@@ -133,73 +105,40 @@
       var jar = getJar(rootDir);
       if (jar) {
         var tmpdir = extractJarToTmp(jar);
         rootDir = "file://" + tmpdir.path + '/';
       }
       var url = rootDir + "scroll.html#link1";
 
       gQueue = new eventQueue();
-      gQueue.push(new loadTab("tabBrowser", url));
-      gQueue.push(new advanceFocusIntoTab("tabBrowser"));
+
+      gQueue.push(new loadTab(url));
+      gQueue.push(new loadTabInBackground(url));
+      gQueue.push(new switchToBackgroundTab());
+      gQueue.onFinish = function() { closeBrowserWindow(); }
+
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
-    addA11yLoadEvent(doTest);
+    openBrowserWindow(doTest);
   ]]>
   </script>
 
-  <hbox flex="1" style="overflow: auto;">
+  <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=437607"
-         title="Clicking the 'Skip to main content' link once works, second time fails to initiate a V cursor jump">
-        Mozilla Bug 437607
-      </a><br/>
-      <a target="_blank"
-         href="https://bugzilla.mozilla.org/show_bug.cgi?id=519303"
-         title="Same page links to targets with content fires scrolling start accessible event on leaf text node">
-        Mozilla Bug 519303
-      </a>
-      <a target="_blank"
          href="https://bugzilla.mozilla.org/show_bug.cgi?id=691734"
          title="Make sure scrolling start event is fired when document receive focus">
         Mozilla Bug 691734
       </a>
 
       <p id="display"></p>
       <div id="content" style="display: none">
       </div>
       <pre id="test">
       </pre>
     </body>
 
-    <vbox flex="1">
-      <!-- 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>
-      <keyset>
-        <key id="key_close"/>
-      </keyset>
-
-      <hbox>
-      <tabs id="tabbrowser-tabs" class="tabbrowser-tabs"
-            tabbrowser="tabBrowser"
-            flex="1">
-        <tab class="tabbrowser-tab" selected="true" label="tab"/>
-      </tabs>
-      </hbox>
-      <tabbrowser id="tabBrowser"
-                  type="content-primary"
-                  tabcontainer="tabbrowser-tabs"
-                  flex="1"/>
-    </vbox>
-    <toolbar id="addon-bar"/>
-  </hbox>
-
+    <vbox id="eventdump"></vbox>
+  </vbox>
 </window>