Bug 598957 - Fix viewport browser-chrome tests failures [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Thu, 30 Sep 2010 06:43:49 -0700
changeset 2109 3b03b8566adf0f294f90fd38d8932c6b284c539b
parent 2108 4d6d357ea80816b0224b6a079c2cc9e0242f5110
child 2110 b542f025d5b1e9196245913493fe481321d86aac
push id1775
push usermbrubeck@mozilla.com
push dateThu, 30 Sep 2010 13:44:23 +0000
reviewersmfinkle
bugs598957
Bug 598957 - Fix viewport browser-chrome tests failures [r=mfinkle]
chrome/content/bindings/browser.xml
chrome/tests/browser_viewport.js
--- a/chrome/content/bindings/browser.xml
+++ b/chrome/content/bindings/browser.xml
@@ -71,17 +71,17 @@
 
       <field name="_searchEngines">[]</field>
       <property name="searchEngines"
                 onget="return this._searchEngines"
                 readonly="true"/>
 
       <field name="_documentURI">null</field>
       <property name="documentURI"
-                onget="return Services.io.newURI(this._documentURI, null, null)"
+                onget="return this._documentURI ? Services.io.newURI(this._documentURI, null, null) : null"
                 readonly="true"/>
 
       <field name="contentWindowId">null</field>
 
       <property name="messageManager"
                 onget="return this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader.messageManager;"
                 readonly="true"/>
 
@@ -628,19 +628,16 @@
           STOP_ALL: 3,
 
           canGoBack: false,
           canGoForward: false,
           goBack: function() { this._sendMessage("WebNavigation:GoBack", {}); },
           goForward: function() { this._sendMessage("WebNavigation:GoForward", {}); },
           gotoIndex: function(aIndex) { this._sendMessage("WebNavigation:GotoIndex", {index: aIndex}); },
           loadURI: function(aURI, aLoadFlags, aReferrer, aPostData, aHeaders) {
-            try {
-              this._currentURI = this._browser._ios.newURI(aURI, null, null);
-            } catch(e) {}
             this._browser._contentTitle = "";
             this._sendMessage("WebNavigation:LoadURI", {uri: aURI, flags: aLoadFlags});
           },
           reload: function(aReloadFlags) { this._sendMessage("WebNavigation:Reload", {flags: aReloadFlags}); },
           stop: function(aStopFlags) { this._sendMessage("WebNavigation:Stop", {flags: aStopFlags}); },
           get document() { Components.utils.reportError("contentDocument is not available"); return null; },
           get currentURI() {
             if (!this._currentURI)
--- a/chrome/tests/browser_viewport.js
+++ b/chrome/tests/browser_viewport.js
@@ -62,22 +62,28 @@ let testData = [
   { width: 200,     scale: 4.00 },
   { width: 2000,    scale: 1.125,  minScale: 1.125 },
   { width: 266.67,  scale: 3,      maxScale: 3 },
   { width: 2000,    scale: 1.125 },
   { width: 10000,   scale: 4 },
   { width: 533.33,  scale: 1.5,    disableZoom: true }
 ];
 
+let isLocalScheme = Util.isLocalScheme;
+
 //------------------------------------------------------------------------------
 // Entry point (must be named "test")
 function test() {
   // This test is async
   waitForExplicitFinish();
 
+  // We need our test pages to open in remote tabs, until zooming in local tabs
+  // is fixed (bug 597081).
+  Util.isLocalScheme = function() { return false; };
+
   working_tab = Browser.addTab(testURL_blank, true);
   ok(working_tab, "Tab Opened");
 
   waitFor(function() { startTest(0); }, pageLoaded(testURL_blank));
 }
 
 function startTest(n) {
   BrowserUI.goToURI(testURL_blank);
@@ -86,18 +92,17 @@ function startTest(n) {
 
 function verifyBlank(n) {
   return function() {
     // Do sanity tests
     var uri = working_tab.browser.currentURI.spec;
     is(uri, testURL_blank, "URL Matches blank page "+n);
 
     // Check viewport settings
-    let style = window.getComputedStyle(working_tab.browser, null);
-    is(style.width, "980px", "Normal 'browser' width is 980 pixels");
+    is(working_tab.browser.contentWindowWidth, 980, "Normal 'browser' width is 980 pixels");
 
     loadTest(n);
   }
 }
 
 function loadTest(n) {
   let url = testURL(n);
   BrowserUI.goToURI(url);
@@ -127,18 +132,17 @@ function verifyTest(n) {
     is(window.innerWidth, 800, "Test assumes window width is 800px");
     is(Services.prefs.getIntPref("zoom.dpiScale") / 100, 1.5, "Test assumes zoom.dpiScale is 1.5");
 
     // Do sanity tests
     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\.]+/, ""));
+    let actualWidth = working_tab.browser.contentWindowWidth;
     is_approx(actualWidth, parseFloat(data.width), .01, "Viewport width=" + data.width);
 
     let zoomLevel = getBrowser().scale;
     is_approx(zoomLevel, parseFloat(data.scale), .01, "Viewport scale=" + data.scale);
 
     // Test zooming
     if (data.disableZoom) {
       ok(!Browser.selectedTab.allowZoom, "Zoom disabled");
@@ -174,11 +178,12 @@ function verifyTest(n) {
   }
 }
 
 function finishTest(n) {
   if (n+1 < testData.length) {
     startTest(n+1);
   } else {
     Browser.closeTab(working_tab);
+    Util.isLocalScheme = isLocalScheme;
     finish();
   }
 }