The DOM document loaded before it's shown shouldn't have busy state, r=trevor, marcoz
authorAlexander Surkov <surkov.alexander@gmail.com>
Fri, 27 May 2011 11:18:00 +0900
changeset 70221 5f991615ac6a521ff0e240d210e670b48ce6f909
parent 70220 7a6804f6034eb30f3b396ac6fc708c5af1f6b495
child 70222 2b53d3079c78a7d79f39476cf1e3539b80a9691e
push id20244
push usersurkov.alexander@gmail.com
push dateFri, 27 May 2011 02:19:31 +0000
treeherdermozilla-central@5f991615ac6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstrevor, marcoz
milestone7.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
The DOM document loaded before it's shown shouldn't have busy state, r=trevor, marcoz
accessible/src/base/nsDocAccessible.cpp
accessible/tests/mochitest/events/test_docload.html
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -602,16 +602,22 @@ nsDocAccessible::Init()
   NS_LOG_ACCDOCCREATE_FOR("document initialize", mDocument, this)
 
   // Initialize notification controller.
   nsCOMPtr<nsIPresShell> shell(GetPresShell());
   mNotificationController = new NotificationController(this, shell);
   if (!mNotificationController)
     return PR_FALSE;
 
+  // Mark the document accessible as loaded if its DOM document was loaded at
+  // this point (this can happen because a11y is started late or DOM document
+  // having no container was loaded.
+  if (mDocument->GetReadyStateEnum() == nsIDocument::READYSTATE_COMPLETE)
+    mIsLoaded = PR_TRUE;
+
   AddEventListeners();
   return PR_TRUE;
 }
 
 void
 nsDocAccessible::Shutdown()
 {
   if (!mWeakShell) // already shutdown
--- a/accessible/tests/mochitest/events/test_docload.html
+++ b/accessible/tests/mochitest/events/test_docload.html
@@ -113,16 +113,35 @@
         if (aAction == kRemove)
           return "remove iframe";
 
         return "change display style of iframe to " +
           ((aAction == kHide) ? "none" : "block");
       }
     }
 
+    function makeIFrameVisible(aID)
+    {
+      this.DOMNode = getNode(aID);
+
+      this.eventSeq = [
+        new invokerChecker(EVENT_REORDER, this.DOMNode.parentNode)
+      ];
+
+      this.invoke = function makeIFrameVisible_invoke()
+      {
+        this.DOMNode.style.visibility = "visible";
+      }
+
+      this.getID = function makeIFrameVisible_getID()
+      {
+        return "The accessible for DOM document loaded before it's shown shouldn't have busy state.";
+      }
+    }
+
     function openDialogWnd(aURL)
     {
       // Get application root accessible.
       var docAcc = getAccessible(document);
       while (docAcc) {
         this.mRootAcc = docAcc;
         try {
           docAcc = docAcc.parent;
@@ -219,33 +238,51 @@
 
     ////////////////////////////////////////////////////////////////////////////
     // Do tests
 
     var gQueue = null;
 
     // Debug stuff.
     // gA11yEventDumpID = "eventdump";
-    // gA11yEventDumpToConsole = true;
+    //gA11yEventDumpToConsole = true;
 
     function doTests()
     {
       gQueue = new eventQueue();
 
       gQueue.push(new changeIframeSrc("iframe", "about:"));
       gQueue.push(new changeIframeSrc("iframe", "about:buildconfig"));
       gQueue.push(new morphIFrame("iframe", kHide));
       gQueue.push(new morphIFrame("iframe", kShow));
       gQueue.push(new morphIFrame("iframe", kRemove));
+      gQueue.push(new makeIFrameVisible("iframe2"));
       gQueue.push(new openDialogWnd("about:"));
       gQueue.push(new openWndShutdownDoc());
 
+      gQueue.onFinish = doLastCallTests;
+
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
+    function doLastCallTests()
+    {
+      //////////////////////////////////////////////////////////////////////////
+      // makeIFrameVisible() test, part2
+
+      // The document shouldn't have busy state (the DOM document was loaded
+      // before its accessible was created). Do this test lately to make sure
+      // the content of document accessible was created initially, prior to this
+      // the document accessible keeps busy state. The initial creation happens
+      // asynchronously after document creation, there are no events we could
+      // use to catch it.
+      var iframeDoc = getAccessible("iframe2").firstChild;
+      testStates(iframeDoc, 0, 0, STATE_BUSY);
+    }
+
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTests);
   </script>
 </head>
 
 <body>
 
   <a target="_blank"
@@ -263,18 +300,24 @@
      title="Reorganize accessible document handling">
     Mozilla Bug 566103
   </a><br>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=571459"
      title="Shutdown document accessible when presshell goes away">
     Mozilla Bug 571459
   </a>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=658185"
+     title="The DOM document loaded before it's shown shouldn't have busy state">
+    Mozilla Bug 658185
+  </a>
 
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <div id="testContainer"><iframe id="iframe"></iframe></div>
+  <div id="testContainer2"><iframe id="iframe2" src="about:" style="visibility: hidden;"></iframe></div>
   <div id="eventdump"></div>
 </body>
 </html>