Port more reliable branch test from bug 304198 to trunk to fix intermittent oranges, a=beltzner/shaver
authorGavin Sharp <gavin@mozilla.com>
Thu, 28 May 2009 18:43:58 -0400
changeset 28809 bfb383af1903bc620eef56a3baabbc33276cc86d
parent 28808 bb7d5f416b60fd02d156b8b8153b14cef5b8cb74
child 28818 ac3e487c5fffad1d1ef9f3353f3cadad297b1f66
child 29184 770ae01e42115f4a98f9f92080f5d64688d9d504
push id7272
push usergsharp@mozilla.com
push dateThu, 28 May 2009 22:44:11 +0000
treeherdermozilla-central@bfb383af1903 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbeltzner, shaver
bugs304198
milestone1.9.2a1pre
Port more reliable branch test from bug 304198 to trunk to fix intermittent oranges, a=beltzner/shaver
browser/base/content/test/browser_bug304198.js
--- a/browser/base/content/test/browser_bug304198.js
+++ b/browser/base/content/test/browser_bug304198.js
@@ -33,101 +33,74 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 function test() {
   waitForExplicitFinish();
 
-  let charsToDelete, deletedURLTab, fullURLTab, partialURLTab, testPartialURL, testURL;
+  let deletedURLTab, fullURLTab, partialURLTab, testPartialURL, testURL;
 
-  charsToDelete = 5;
   deletedURLTab = gBrowser.addTab();
   fullURLTab = gBrowser.addTab();
   partialURLTab = gBrowser.addTab();
+  testPartialURL = "http://example.org/brow";
   testURL = "http://example.org/browser/browser/base/content/test/dummy_page.html";
 
-  testPartialURL = testURL.substr(0, (testURL.length - charsToDelete));
-
   function cleanUp() {
 
     gBrowser.removeTab(fullURLTab);
     gBrowser.removeTab(partialURLTab);
     gBrowser.removeTab(deletedURLTab);
   }
 
-  function cycleTabs() {
+  // function borrowed from browser_bug386835.js
+  function load(tab, url, cb) {
+    tab.linkedBrowser.addEventListener("load", function (event) {
+      event.currentTarget.removeEventListener("load", arguments.callee, true);
+      cb();
+    }, true);
+    tab.linkedBrowser.loadURI(url);
+  }
+
+  function runTests() {
+    gBrowser.selectedTab = fullURLTab;
+    is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to fullURLTab');
+
+    gBrowser.selectedTab = partialURLTab;
+    is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to partialURLTab');
+
+    // simulate the user removing part of the url from the location bar
+    gBrowser.userTypedValue = testPartialURL;
+    URLBarSetURI();
+    is(gURLBar.value, testPartialURL, 'gURLBar.value should be testPartialURL (just set)');
+
+    gBrowser.selectedTab = deletedURLTab;
+    is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to deletedURLTab');
+
+    // simulate the user removing the whole url from the location bar
+    gBrowser.userTypedValue = '';
+    URLBarSetURI();
+    is(gURLBar.value, '', 'gURLBar.value should be "" (just set)');
+
+    // now cycle the tabs and make sure everything looks good
     gBrowser.selectedTab = fullURLTab;
     is(gURLBar.value, testURL, 'gURLBar.value should be testURL after switching back to fullURLTab');
 
     gBrowser.selectedTab = partialURLTab;
     is(gURLBar.value, testPartialURL, 'gURLBar.value should be testPartialURL after switching back to partialURLTab');
 
     gBrowser.selectedTab = deletedURLTab;
     is(gURLBar.value, '', 'gURLBar.value should be "" after switching back to deletedURLTab');
 
     gBrowser.selectedTab = fullURLTab;
     is(gURLBar.value, testURL, 'gURLBar.value should be testURL after switching back to fullURLTab');
   }
 
-  // function borrowed from browser_bug386835.js
-  function load(tab, url, cb) {
-    tab.linkedBrowser.addEventListener("load", function (event) {
-      event.currentTarget.removeEventListener("load", arguments.callee, true);
-      cb();
-    }, true);
-    tab.linkedBrowser.loadURI(url);
-  }
-
-  function prepareDeletedURLTab() {
-    gBrowser.selectedTab = deletedURLTab;
-    is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to deletedURLTab');
-
-    // simulate the user removing the whole url from the location bar
-    gPrefService.setBoolPref("browser.urlbar.clickSelectsAll", true);
-    gURLBar.focus();
-
-    EventUtils.synthesizeKey("VK_BACK_SPACE", {});
-    
-    is(gURLBar.value, '', 'gURLBar.value should be "" (just set)');
-    gPrefService.clearUserPref("browser.urlbar.clickSelectsAll");
-  }
-
-  function prepareFullURLTab() {
-    gBrowser.selectedTab = fullURLTab;
-    is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to fullURLTab');
-  }
-
-  function preparePartialURLTab() {
-    gBrowser.selectedTab = partialURLTab;
-    is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to partialURLTab');
-
-    // simulate the user removing part of the url from the location bar
-    gPrefService.setBoolPref("browser.urlbar.clickSelectsAll", false);
-    gURLBar.focus();
-    
-    for(let i = 0; i < charsToDelete; ++i) {
-      EventUtils.synthesizeKey("VK_BACK_SPACE", {});
-    }
-
-    is(gURLBar.value, testPartialURL, 'gURLBar.value should be testPartialURL (just set)');
-    gPrefService.clearUserPref("browser.urlbar.clickSelectsAll");
-  }
-
-  function runTests() {
-    // prepare the three tabs required by this test
-    prepareFullURLTab();
-    preparePartialURLTab();
-    prepareDeletedURLTab();
-
-    // now cycle the tabs and make sure everything looks good
-    cycleTabs();
-  }
-
   load(deletedURLTab, testURL, function() {
     load(fullURLTab, testURL, function() {
       load(partialURLTab, testURL, function() {
         runTests();
         cleanUp();
         finish();
       });
     });