Bug 1018154 - part 2: adjust tests now that mayInheritPrincipal has gone the way of the dodo, r=Unfocused
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 01 Jul 2014 14:28:49 +0100
changeset 191973 e6e23faf705f43b0d9dab442a6521cc9c62ce75e
parent 191972 474e76c20c5577037a9ac832ebb3a9c3157505e4
child 191974 740ef090bec00046b6c99485864707a6f49cc586
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersUnfocused
bugs1018154
milestone33.0a1
Bug 1018154 - part 2: adjust tests now that mayInheritPrincipal has gone the way of the dodo, r=Unfocused
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_getshortcutoruri.js
browser/base/content/test/general/browser_locationBarExternalLoad.js
browser/base/content/test/general/browser_middleMouse_inherit.js
browser/base/content/test/general/browser_middleMouse_noJSPaste.js
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -304,21 +304,19 @@ skip-if = e10s # Bug ?????? - this test 
 [browser_keywordSearch.js]
 skip-if = e10s # Bug 921957 - remote webprogress doesn't supply originalURI attribute on the request object
 [browser_keywordSearch_postData.js]
 skip-if = e10s # Bug ?????? - test directly manipulates content (gBrowser.contentDocument.body.textContent)
 [browser_lastAccessedTab.js]
 skip-if = toolkit == "windows" # Disabled on Windows due to frequent failures (bug 969405)
 [browser_locationBarCommand.js]
 skip-if = os == "linux" || e10s # Linux: Intermittent failures, bug 917535; e10s: Bug ?????? - Focus issues (There should be no focused element - Got [object XULElement], expected null)
-[browser_locationBarExternalLoad.js]
-skip-if = e10s # Bug ?????? - URL bar issues ("There should be no focused element - Got [object XULElement], expected null")
 [browser_menuButtonFitts.js]
 skip-if = os != "win" || e10s # The Fitts Law menu button is only supported on Windows (bug 969376); # Bug ?????? - URL bar issues ("There should be no focused element - Got [object XULElement], expected null")
-[browser_middleMouse_inherit.js]
+[browser_middleMouse_noJSPaste.js]
 skip-if = e10s # Bug 921952 - Content:Click event issues
 [browser_minimize.js]
 skip-if = e10s # Bug ?????? - test directly manipulates content (TypeError: gBrowser.docShell is null)
 [browser_mixedcontent_securityflags.js]
 skip-if = e10s # Bug ?????? - test directly manipulates content ("cannot ipc non-cpow object")
 [browser_notification_tab_switching.js]
 skip-if = e10s # Bug ?????? - uncaught exception - Error: cannot ipc non-cpow object at chrome://mochitests/content/browser/browser/base/content/test/general/browser_notification_tab_switching.js:32
 [browser_offlineQuotaNotification.js]
--- a/browser/base/content/test/general/browser_getshortcutoruri.js
+++ b/browser/base/content/test/general/browser_getshortcutoruri.js
@@ -6,20 +6,19 @@ function getPostDataString(aIS) {
             createInstance(Ci.nsIScriptableInputStream);
   sis.init(aIS);
   var dataLines = sis.read(aIS.available()).split("\n");
 
   // only want the last line
   return dataLines[dataLines.length-1];
 }
 
-function keywordResult(aURL, aPostData, aIsUnsafe) {
+function keywordResult(aURL, aPostData) {
   this.url = aURL;
   this.postData = aPostData;
-  this.isUnsafe = aIsUnsafe;
 }
 
 function keyWordData() {}
 keyWordData.prototype = {
   init: function(aKeyWord, aURL, aPostData, aSearchWord) {
     this.keyword = aKeyWord;
     this.uri = makeURI(aURL);
     this.postData = aPostData;
@@ -48,30 +47,30 @@ var testData = [
 
   [new bmKeywordData("bmpostget", "http://bmpostget/search1=%s", "search2=%s", "foo3"),
    new keywordResult("http://bmpostget/search1=foo3", "search2=foo3")],
 
   [new bmKeywordData("bmget-nosearch", "http://bmget-nosearch/", null, ""),
    new keywordResult("http://bmget-nosearch/", null)],
 
   [new searchKeywordData("searchget", "http://searchget/?search={searchTerms}", null, "foo4"),
-   new keywordResult("http://searchget/?search=foo4", null, true)],
+   new keywordResult("http://searchget/?search=foo4", null)],
 
   [new searchKeywordData("searchpost", "http://searchpost/", "search={searchTerms}", "foo5"),
-   new keywordResult("http://searchpost/", "search=foo5", true)],
+   new keywordResult("http://searchpost/", "search=foo5")],
 
   [new searchKeywordData("searchpostget", "http://searchpostget/?search1={searchTerms}", "search2={searchTerms}", "foo6"),
-   new keywordResult("http://searchpostget/?search1=foo6", "search2=foo6", true)],
+   new keywordResult("http://searchpostget/?search1=foo6", "search2=foo6")],
 
   // Bookmark keywords that don't take parameters should not be activated if a
   // parameter is passed (bug 420328).
   [new bmKeywordData("bmget-noparam", "http://bmget-noparam/", null, "foo7"),
-   new keywordResult(null, null, true)],
+   new keywordResult(null, null)],
   [new bmKeywordData("bmpost-noparam", "http://bmpost-noparam/", "not_a=param", "foo8"),
-   new keywordResult(null, null, true)],
+   new keywordResult(null, null)],
 
   // Test escaping (%s = escaped, %S = raw)
   // UTF-8 default
   [new bmKeywordData("bmget-escaping", "http://bmget/?esc=%s&raw=%S", null, "fo"),
    new keywordResult("http://bmget/?esc=fo%C3%A9&raw=fo", null)],
   // Explicitly-defined ISO-8859-1
   [new bmKeywordData("bmget-escaping2", "http://bmget/?esc=%s&raw=%S&mozcharset=ISO-8859-1", null, "fo"),
    new keywordResult("http://bmget/?esc=fo%E9&raw=fo", null)],
@@ -83,17 +82,17 @@ var testData = [
   // Explicitly-defined ISO-8859-1
   [new bmKeywordData("bmget-escaping2", "http://bmget/?esc=%s&raw=%S&mozcharset=ISO-8859-1", null, "+/@"),
    new keywordResult("http://bmget/?esc=%2B%2F%40&raw=+/@", null)],
 
   // Test using a non-bmKeywordData object, to test the behavior of
   // getShortcutOrURIAndPostData for non-keywords (setupKeywords only adds keywords for
   // bmKeywordData objects)
   [{keyword: "http://gavinsharp.com"},
-   new keywordResult(null, null, true)]
+   new keywordResult(null, null)]
 ];
 
 function test() {
   waitForExplicitFinish();
 
   setupKeywords();
 
   Task.spawn(function() {
@@ -104,17 +103,16 @@ function test() {
       if (data.searchWord)
         query += " " + data.searchWord;
       let returnedData = yield new Promise(
         resolve => getShortcutOrURIAndPostData(query, resolve));
       // null result.url means we should expect the same query we sent in
       let expected = result.url || query;
       is(returnedData.url, expected, "got correct URL for " + data.keyword);
       is(getPostDataString(returnedData.postData), result.postData, "got correct postData for " + data.keyword);
-      is(returnedData.mayInheritPrincipal, !result.isUnsafe, "got correct mayInheritPrincipal for " + data.keyword);
     }
     cleanupKeywords();
   }).then(finish);
 }
 
 var gBMFolder = null;
 var gAddedEngines = [];
 function setupKeywords() {
deleted file mode 100644
--- a/browser/base/content/test/general/browser_locationBarExternalLoad.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-function test() {
-  waitForExplicitFinish();
-
-  nextTest();
-}
-
-let urls = [
-  "javascript:'foopy';",
-  "data:text/html,<body>hi"
-];
-
-function urlEnter(url) {
-  gURLBar.value = url;
-  gURLBar.focus();
-  EventUtils.synthesizeKey("VK_RETURN", {});
-}
-
-function urlClick(url) {
-  gURLBar.value = url;
-  gURLBar.focus();
-  let goButton = document.getElementById("urlbar-go-button");
-  EventUtils.synthesizeMouseAtCenter(goButton, {});
-}
-
-function nextTest() {
-  let url = urls.shift();
-  if (url) {
-    testURL(url, urlEnter, function () {
-      testURL(url, urlClick, nextTest);
-    });
-  }
-  else
-    finish();
-}
-
-function testURL(url, loadFunc, endFunc) {
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
-  registerCleanupFunction(function () {
-    gBrowser.removeTab(tab);
-  });
-  addPageShowListener(function () {
-    let pagePrincipal = gBrowser.contentPrincipal;
-    loadFunc(url);
-
-    addPageShowListener(function () {
-      let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
-      is(fm.focusedElement, null, "should be no focused element");
-      is(fm.focusedWindow, gBrowser.contentWindow, "content window should be focused");
-
-      ok(!gBrowser.contentPrincipal.equals(pagePrincipal),
-         "load of " + url + " by " + loadFunc.name + " should produce a page with a different principal");
-      endFunc();
-    });
-  });
-}
-
-function addPageShowListener(func) {
-  gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() {
-    gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false);
-    func();
-  });
-}
rename from browser/base/content/test/general/browser_middleMouse_inherit.js
rename to browser/base/content/test/general/browser_middleMouse_noJSPaste.js
--- a/browser/base/content/test/general/browser_middleMouse_inherit.js
+++ b/browser/base/content/test/general/browser_middleMouse_noJSPaste.js
@@ -15,17 +15,17 @@ function test() {
     Services.prefs.clearUserPref(autoScrollPref);
     gBrowser.removeTab(tab);
   });
 
   addPageShowListener(function () {
     let pagePrincipal = gBrowser.contentPrincipal;
 
     // copy javascript URI to the clipboard
-    let url = "javascript:1+1";
+    let url = "javascript:http://www.example.com/";
     waitForClipboard(url,
       function() {
         Components.classes["@mozilla.org/widget/clipboardhelper;1"]
                   .getService(Components.interfaces.nsIClipboardHelper)
                   .copyString(url, document);
       },
       function () {
         // Middle click on the content area
@@ -34,19 +34,17 @@ function test() {
       },
       function() {
         ok(false, "Failed to copy URL to the clipboard");
         finish();
       }
     );
 
     addPageShowListener(function () {
-      is(gBrowser.currentURI.spec, url, "url loaded by middle click");
-      ok(!gBrowser.contentPrincipal.equals(pagePrincipal),
-         "middle click load of " + url + " should produce a page with a different principal");
+      is(gBrowser.currentURI.spec, url.replace(/^javascript:/, ""), "url loaded by middle click doesn't include JS");
       finish();
     });
   });
 }
 
 function addPageShowListener(func) {
   gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() {
     gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false);