Bug 597022 - browser-chrome unittests have references to tile-container [r=mfinkle,mbrubeck]
authorVivien Nicolas <21@vingtetun.org>
Thu, 16 Sep 2010 21:29:03 +0200
changeset 66663 0407a246fc73338a8252f36dcecebd6f61a1de81
parent 66662 db1051dc93c144d32fdb42d9d1b5bc62fbcbec3e
child 66664 4c69e6c4e106d86e6aedf57ae399f1f14c0122be
push id19389
push userffxbld
push dateWed, 06 Apr 2011 21:33:21 +0000
treeherdermozilla-central@8e9f90073a20 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, mbrubeck
bugs597022
Bug 597022 - browser-chrome unittests have references to tile-container [r=mfinkle,mbrubeck]
mobile/chrome/content/browser.xul
mobile/chrome/tests/browser_awesomescreen.js
mobile/chrome/tests/browser_bookmarks_star.js
mobile/chrome/tests/browser_click_content.js
mobile/chrome/tests/browser_mainui.js
mobile/chrome/tests/browser_select.js
mobile/chrome/tests/browser_viewport.js
mobile/chrome/tests/head.js
--- a/mobile/chrome/content/browser.xul
+++ b/mobile/chrome/content/browser.xul
@@ -265,17 +265,17 @@
 #endif
                 </toolbar>
               </box>
             </box>
 
             <notificationbox id="notifications" class="window-width"/>
 
             <!-- Content viewport -->
-            <vbox class="window-width window-height">
+            <vbox id="content-viewport" class="window-width window-height">
               <stack id="tile-stack" class="window-width" flex="1">
               <!-- Content viewport -->
                 <html:div>
                   <html:div id="browsers"/>
                   <html:canvas id="content-overlay" style="display: none; position: absolute; z-index: 1000; left: 0; top: 0;"/>
                 </html:div>
                 <html:div id="inputhandler-overlay" style="z-index: 1001" tabindex="-1"/>
               </stack>
--- a/mobile/chrome/tests/browser_awesomescreen.js
+++ b/mobile/chrome/tests/browser_awesomescreen.js
@@ -43,17 +43,13 @@ gTests.push({
       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");
+    is(BrowserUI._edit.readOnly, false, "urlbar input textbox should not be readonly once it is open");
 
     runNextTest();
   }
 });
--- a/mobile/chrome/tests/browser_bookmarks_star.js
+++ b/mobile/chrome/tests/browser_bookmarks_star.js
@@ -90,29 +90,29 @@ gTests.push({
     starbutton.click();
     
     waitFor(gCurrentTest.onPopupGone2, function() { return document.getElementById("bookmark-popup").hidden == true; });
   },
 
   onPopupGone2: function() {
     // Make sure it's hidden again
     is(document.getElementById("bookmark-popup").hidden, true, "Bookmark popup should be hidden by clicking star");
-    
+
     // Let's make it appear again and continue the test
-    var starbutton = document.getElementById("tool-star");
+    let starbutton = document.getElementById("tool-star");
     starbutton.click();
-    
+
     waitFor(gCurrentTest.onPopupReady3, function() { return document.getElementById("bookmark-popup").hidden == false; });
   },
 
   onPopupReady3: function() {
     // Let's make it disappear again by clicking somewhere
-    var contentarea = document.getElementById("tile-container");
+    let contentarea = document.getElementById("browsers");
     EventUtils.synthesizeMouse(contentarea, contentarea.clientWidth / 2, contentarea.clientHeight / 2, {});
-    
+
     waitFor(gCurrentTest.onPopupGone3, function() { return document.getElementById("bookmark-popup").hidden == true; });
   },
 
   onPopupGone3: function() {
     // Make sure it's hidden again
     is(document.getElementById("bookmark-popup").hidden, true, "Bookmark popup should be hidden by clicking in content");
     
     BrowserUI.closeTab(this._currentTab);
--- a/mobile/chrome/tests/browser_click_content.js
+++ b/mobile/chrome/tests/browser_click_content.js
@@ -1,60 +1,60 @@
 let testURL_click = "chrome://mochikit/content/browser/mobile/chrome/browser_click_content.html";
 
-let newTab;
+let currentTab;
 let element;
 let isClickFired = false;
 let clickPosition = { x: null, y: null};
-let isLoading = function() {
-  return !newTab.isLoading() &&
-    newTab.browser.currentURI.spec != "about:blank";
-};
 
 //------------------------------------------------------------------------------
 // Entry point (must be named "test")
 function test() {
   // This test is async
   waitForExplicitFinish();
 
   // Add new tab
-  newTab = Browser.addTab(testURL_click, true);
-  ok(newTab, "Tab Opened");
+  currentTab = Browser.addTab(testURL_click, true);
+  ok(currentTab, "Tab Opened");
 
-  // Wait for tab load (need to check the tab "loading", not the document "loading")
-  waitFor(testClickAndPosition, isLoading);
+  // Wait for the tab to load, then do the test
+  messageManager.addMessageListener("pageshow", function() {
+  if (currentTab.browser.currentURI.spec == testURL_click) {
+    messageManager.removeMessageListener("pageshow", arguments.callee);
+    testClickAndPosition();
+  }});
 }
 
 function clickFired(aEvent) {
   isClickFired = true;
   let [x, y] = Browser.browserViewToClient(aEvent.clientX, aEvent.clientY);
   clickPosition.x = x;
   clickPosition.y = y;
 }
 
 function testClickAndPosition() {
   // Do sanity tests
-  let uri = newTab.browser.currentURI.spec;
+  let uri = currentTab.browser.currentURI.spec;
   is(uri, testURL_click, "URL Matches newly created Tab");
 
   // Check click
-  element = newTab.browser.contentDocument.getElementById("iframe-1");
+  element = currentTab.browser.contentDocument.getElementById("iframe-1");
   element.addEventListener("click", clickFired, true);
 
   EventUtils.synthesizeMouseForContent(element, 1, 1, {}, window);
   waitFor(checkClick, function() { return isClickFired });
 }
 
 function checkClick() {
   ok(isClickFired, "Click handler fired");
   element.removeEventListener("click", clickFired, true);
 
   // Check position
   isClickFired = false;
-  element = newTab.browser.contentDocument.documentElement;
+  element = currentTab.browser.contentDocument.documentElement;
   element.addEventListener("click", clickFired, true);
 
   let rect = getBoundingContentRect(element);
   EventUtils.synthesizeMouse(element, 1, rect.height + 10, {}, window);
   waitFor(checkPosition, function() { return isClickFired });
 }
 
 function checkPosition() {
@@ -63,33 +63,33 @@ function checkPosition() {
   let rect = getBoundingContentRect(element);
   is(clickPosition.x, 1, "X position is correct");
   is(clickPosition.y, rect.height + 10, "Y position is correct");
 
   checkThickBorder();
 }
 
 function checkThickBorder() {
-  let frame = newTab.browser.contentDocument.getElementById("iframe-2");
+  let frame = currentTab.browser.contentDocument.getElementById("iframe-2");
   let element = frame.contentDocument.getElementsByTagName("input")[0];
 
   let frameRect = getBoundingContentRect(frame);
   let frameLeftBorder = window.getComputedStyle(frame, "").borderLeftWidth;
   let frameTopBorder = window.getComputedStyle(frame, "").borderTopWidth;
 
   let elementRect = getBoundingContentRect(element);
   ok((frameRect.left + parseInt(frameLeftBorder)) < elementRect.left, "X position of nested element ok");
   ok((frameRect.top + parseInt(frameTopBorder)) < elementRect.top, "Y position of nested element ok");
 
   close();
 }
 
 function close() {
   // Close the tab
-  Browser.closeTab(newTab);
+  Browser.closeTab(currentTab);
 
   // We must finialize the tests
   finish();
 }
 
 // XXX copied from chrome/content/content.js
 function getBoundingContentRect(aElement) {
   if (!aElement)
--- a/mobile/chrome/tests/browser_mainui.js
+++ b/mobile/chrome/tests/browser_mainui.js
@@ -14,23 +14,14 @@ function test() {
   isnot(browser, null, "Should have a browser");
   
   is(browser.currentURI.spec, Browser.selectedTab.browser.currentURI.spec, "selectedBrowser == selectedTab.browser");
   
   testContentContainerSize();
 }
 
 function testContentContainerSize() {
-  let tiles = document.getElementById("tile-container");
-  let oldtilesstyle = tiles.getAttribute("style");
+  let container = document.getElementById("content-viewport");
 
-  try {
-    tiles.style.width = (window.innerWidth + 100) + "px";
-    tiles.style.height = (window.innerHeight + 100) + "px";
-    let container = Browser.contentScrollbox;
-    let rect = container.getBoundingClientRect();
-    ok(rect.width == window.innerWidth, "Content container is same width as window");
-    ok(rect.height == window.innerHeight, "Content container is same height as window");
-  }
-  finally {
-    tiles.setAttribute("style", oldtilesstyle);
-  }
+  let rect = container.getBoundingClientRect();
+  ok(rect.width == window.innerWidth, "Content container is same width as window");
+  ok(rect.height == window.innerHeight, "Content container is same height as window");
 }
--- a/mobile/chrome/tests/browser_select.js
+++ b/mobile/chrome/tests/browser_select.js
@@ -21,17 +21,17 @@ function test() {
   });
 }
 
 function onPageReady() {
   let combo = new_tab.browser.contentDocument.getElementById("combobox");
   isnot(combo, null, "Get the select from web content");
 
   // Sending a synthesized event to the combo is not working
-  let container = document.getElementById("tile-container");
+  let container = document.getElementById("inputhandler-overlay");
   let rect = Browser.browserViewToClientRect(Rect.fromRect(combo.getBoundingClientRect()));
   container.customClicker.singleClick(rect.left + 1, rect.top + 1);
 
   waitFor(onUIReady, function() { return document.getElementById("select-container").hidden == false; });
 }
 
 function onUIReady() {
   let selectui = document.getElementById("select-container");
--- a/mobile/chrome/tests/browser_viewport.js
+++ b/mobile/chrome/tests/browser_viewport.js
@@ -131,49 +131,48 @@ function verifyTest(n) {
     var uri = working_tab.browser.currentURI.spec;
     is(uri, testURL(n), "URL is "+testURL(n));
 
     let data = testData[n];
     let style = window.getComputedStyle(working_tab.browser, null);
     let actualWidth = parseFloat(style.width.replace(/[^\d\.]+/, ""));
     is_approx(actualWidth, parseFloat(data.width), .01, "Viewport width=" + data.width);
 
-    let bv = Browser._browserView;
-    let zoomLevel = bv.getZoomLevel();
-    is_approx(bv.getZoomLevel(), parseFloat(data.scale), .01, "Viewport scale=" + data.scale);
+    let zoomLevel = getBrowser().scale;
+    is_approx(zoomLevel, parseFloat(data.scale), .01, "Viewport scale=" + data.scale);
 
     // Test zooming
     if (data.disableZoom) {
-      ok(!bv.allowZoom, "Zoom disabled");
+      ok(!Browser.selectedTab.allowZoom, "Zoom disabled");
 
       Browser.zoom(-1);
-      is(bv.getZoomLevel(), zoomLevel, "Zoom in does nothing");
+      is(getBrowser().scale, zoomLevel, "Zoom in does nothing");
 
       Browser.zoom(1);
-      is(bv.getZoomLevel(), zoomLevel, "Zoom out does nothing");
+      is(getBrowser().scale, zoomLevel, "Zoom out does nothing");
     }
     else {
-      ok(bv.allowZoom, "Zoom enabled");
+      ok(Browser.selectedTab.allowZoom, "Zoom enabled");
     }
 
 
     if (data.minScale) {
       do { // Zoom out until we can't go any farther.
-        zoomLevel = bv.getZoomLevel();
+        zoomLevel = getBrowser().scale;
         Browser.zoom(1);
-      } while (bv.getZoomLevel() != zoomLevel);
-      ok(bv.getZoomLevel() >= data.minScale, "Zoom out limited");
+      } while (getBrowser().scale != zoomLevel);
+      ok(getBrowser().scale >= data.minScale, "Zoom out limited");
     }
 
     if (data.maxScale) {
       do { // Zoom in until we can't go any farther.
-        zoomLevel = bv.getZoomLevel();
+        zoomLevel = getBrowser().scale;
         Browser.zoom(-1);
-      } while (bv.getZoomLevel() != zoomLevel);
-      ok(bv.getZoomLevel() <= data.maxScale, "Zoom in limited");
+      } while (getBrowser().scale != zoomLevel);
+      ok(getBrowser().scale <= data.maxScale, "Zoom in limited");
     }
 
     finishTest(n);
   }
 }
 
 function finishTest(n) {
   if (n+1 < testData.length) {
--- a/mobile/chrome/tests/head.js
+++ b/mobile/chrome/tests/head.js
@@ -19,17 +19,17 @@ function makeURI(spec) {
 
 EventUtils.synthesizeString = function synthesizeString(aString, aWindow) {
   for (let i = 0; i < aString.length; i++) {
     EventUtils.synthesizeKey(aString.charAt(i), {}, aWindow);
   }
 };
 
 EventUtils.synthesizeMouseForContent = function synthesizeMouseForContent(aElement, aOffsetX, aOffsetY, aEvent, aWindow) {
-  let container = document.getElementById("tile-container");
+  let container = document.getElementById("browsers");
   let rect = container.getBoundingClientRect();
 
   EventUtils.synthesizeMouse(aElement, rect.left + aOffsetX, rect.top + aOffsetY, aEvent, aWindow);
 };
 
 let AsyncTests = {
   _tests: {},
   waitFor: function(aMessage, aData, aCallback) {