Bug 590779 - Virtual keyboard should not been showed on urlbar first tap - tests [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Fri, 27 Aug 2010 00:49:51 +0200
changeset 66499 49eefc2a59257eebc77ab7b3f826e76d9f4cbefe
parent 66498 80a1e1d4e56f8163da6a959183ceed82a412ce14
child 66500 ef84bd651ad7987f800ca6e9c4f0d63abaffaaba
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs590779
Bug 590779 - Virtual keyboard should not been showed on urlbar first tap - tests [r=mfinkle]
mobile/chrome/tests/Makefile.in
mobile/chrome/tests/browser_awesomescreen.js
--- a/mobile/chrome/tests/Makefile.in
+++ b/mobile/chrome/tests/Makefile.in
@@ -43,16 +43,17 @@ relativesrcdir  = mobile/chrome
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _BROWSER_FILES = \
   head.js \
   remote_head.js \
   remote_forms.js \
+  browser_awesomescreen.js \
   browser_blank_01.html \
   browser_blank_02.html \
   browser_bookmarks.js \
   browser_bookmarks_star.js \
   browser_bookmarks_tags.js \
   browser_click_content.html \
   browser_click_content.js \
   browser_contacts.js \
new file mode 100644
--- /dev/null
+++ b/mobile/chrome/tests/browser_awesomescreen.js
@@ -0,0 +1,59 @@
+/*
+ * Bug 436069 - Fennec browser-chrome tests to verify correct navigation into the
+ *              differents part of the awesome panel
+ */
+
+let gTests = [];
+let gCurrentTest = null;
+
+function test() {
+  // The "runNextTest" approach is async, so we need to call "waitForExplicitFinish()"
+  // We call "finish()" when the tests are finished
+  waitForExplicitFinish();
+
+  // Start the tests
+  setTimeout(runNextTest, 200);
+}
+
+//------------------------------------------------------------------------------
+// Iterating tests by shifting test out one by one as runNextTest is called.
+function runNextTest() {
+  // Run the next test until all tests completed
+  if (gTests.length > 0) {
+    gCurrentTest = gTests.shift();
+    info(gCurrentTest.desc);
+    gCurrentTest.run();
+  }
+  else {
+    finish();
+  }
+}
+
+//------------------------------------------------------------------------------
+// Case: Test opening the awesome panel and checking the urlbar readonly state
+gTests.push({
+  desc: "Test opening the awesome panel and checking the urlbar readonly state",
+
+  run: function() {
+    is(BrowserUI._edit.readOnly, true, "urlbar input textbox should be readonly");
+
+    let popup = document.getElementById("popup_autocomplete");
+    popup.addEventListener("popupshown", function(aEvent) {
+      popup.removeEventListener("popupshown", arguments.callee, true);
+      gCurrentTest.onPopupReady();
+    }, true);
+
+    BrowserUI.doCommand("cmd_openLocation");
+  },
+
+  onPopupReady: function() {
+    is(Elements.urlbarState.getAttribute("mode"), "edit", "bcast_urlbarState mode attribute should be equal to 'edit'");
+    is(BrowserUI._edit.readOnly, true, "urlbar input textbox be readonly");
+
+    // Simulate a new opening of the awesomescreen
+    BrowserUI.doCommand("cmd_openLocation");
+    is(BrowserUI._edit.readOnly, false, "urlbar input textbox should not be readonly");
+
+    runNextTest();
+  }
+});