Bug 1259431 - Fix test_feed_discovery.html to work with e10s enabled r=jaws
authorGabriele Svelto <gsvelto@mozilla.com>
Tue, 29 Mar 2016 11:05:49 +0200
changeset 290911 ab6ca47677a8219cb08014f02fd41bc7dd83b9a4
parent 290910 4d360ab12c65852cee305224701a024ec28e29e2
child 290912 15058cd337313e26ee0cc699826dcbe7f448c977
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1259431
milestone48.0a1
Bug 1259431 - Fix test_feed_discovery.html to work with e10s enabled r=jaws
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_feed_discovery.js
browser/base/content/test/general/feed_discovery.html
browser/base/content/test/general/mochitest.ini
browser/base/content/test/general/test_feed_discovery.html
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -346,16 +346,18 @@ skip-if = os == "linux" # Linux: Intermi
 [browser_menuButtonFitts.js]
 skip-if = os != "win" # The Fitts Law menu button is only supported on Windows (bug 969376)
 [browser_middleMouse_noJSPaste.js]
 [browser_minimize.js]
 [browser_mixedcontent_securityflags.js]
 tags = mcb
 [browser_offlineQuotaNotification.js]
 skip-if = buildapp == 'mulet'
+[browser_feed_discovery.js]
+support-files = feed_discovery.html
 [browser_gZipOfflineChild.js]
 skip-if = buildapp == 'mulet' # Bug 1066070 - I don't think either popup notifications nor addon install stuff works?
 support-files = test_offline_gzip.html gZipOfflineChild.cacheManifest gZipOfflineChild.cacheManifest^headers^ gZipOfflineChild.html gZipOfflineChild.html^headers^
 [browser_openPromptInBackgroundTab.js]
 support-files = openPromptOffTimeout.html
 [browser_overflowScroll.js]
 [browser_pageInfo.js]
 skip-if = buildapp == 'mulet'
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_feed_discovery.js
@@ -0,0 +1,33 @@
+const URL = "http://mochi.test:8888/browser/browser/base/content/test/general/feed_discovery.html"
+
+/** Test for Bug 377611 **/
+
+add_task(function* () {
+  // Open a new tab.
+  gBrowser.selectedTab = gBrowser.addTab(URL);
+  registerCleanupFunction(() => gBrowser.removeCurrentTab());
+
+  let browser = gBrowser.selectedBrowser;
+  yield BrowserTestUtils.browserLoaded(browser);
+
+  let discovered = browser.feeds;
+  ok(discovered.length > 0, "some feeds should be discovered");
+
+  let feeds = {};
+  for (let aFeed of discovered) {
+    feeds[aFeed.href] = true;
+  }
+
+  yield ContentTask.spawn(browser, feeds, function* (feeds) {
+    for (let aLink of content.document.getElementsByTagName("link")) {
+      // ignore real stylesheets, and anything without an href property
+      if (aLink.type != "text/css" && aLink.href) {
+        if (/bogus/i.test(aLink.title)) {
+          ok(!feeds[aLink.href], "don't discover " + aLink.href);
+        } else {
+          ok(feeds[aLink.href], "should discover " + aLink.href);
+        }
+      }
+    }
+  });
+})
--- a/browser/base/content/test/general/feed_discovery.html
+++ b/browser/base/content/test/general/feed_discovery.html
@@ -1,15 +1,16 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=377611
 -->
   <head>
     <title>Test for feed discovery</title>
+    <meta charset="utf-8">
 
     <!-- Straight up standard -->
     <link rel="alternate" type="application/atom+xml" title="1" href="/1.atom" />
     <link rel="alternate" type="application/rss+xml" title="2" href="/2.rss" />
     <link rel="feed" title="3" href="/3.xml" />
 
     <!-- rel is a space-separated list -->
     <link rel=" alternate " type="application/atom+xml" title="4" href="/4.atom" />
@@ -62,51 +63,11 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     <!-- don't find text/xml by title -->
     <link rel="alternate" type="text/xml" title="Bogus12 RSS and Atom" href="/Bogus12" />
 
     <!-- alternate and stylesheet isn't a feed -->
     <link rel="alternate stylesheet" type="application/rss+xml" title="Bogus13 RSS" href="/Bogus13" />
   </head>
   <body>
-    <script type="text/javascript">
-      window.onload = function() {
-
-        var tests = new Array();
-
-        var currentWindow =
-        SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                              .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-                              .QueryInterface(SpecialPowers.Ci.nsIDocShellTreeItem)
-                              .rootTreeItem
-                              .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                              .getInterface(SpecialPowers.Ci.nsIDOMWindow);
-        var browser = currentWindow.gBrowser.selectedBrowser;
-
-        var discovered = browser.feeds;
-        tests.push({ check: discovered.length > 0,
-                     message: "some feeds should be discovered" });
-
-        var feeds = [];
-
-        for (var aFeed of discovered) {
-          feeds[aFeed.href] = true;
-        }
-
-        for (var aLink of document.getElementsByTagName("link")) {
-          // ignore real stylesheets, and anything without an href property
-          if (aLink.type != "text/css" && aLink.href) {
-            if (/bogus/i.test(aLink.title)) {
-              tests.push({ check: !feeds[aLink.href],
-                           message: "don't discover " + aLink.href });
-            } else {
-              tests.push({ check: feeds[aLink.href],
-                           message: "should discover " + aLink.href });
-            }
-          }
-        }
-        window.arguments[0].tests = tests;
-        window.close();
-      }
-    </script>
   </body>
 </html>
 
--- a/browser/base/content/test/general/mochitest.ini
+++ b/browser/base/content/test/general/mochitest.ini
@@ -2,29 +2,26 @@
 skip-if = buildapp == 'b2g'
 support-files =
   audio.ogg
   bug364677-data.xml
   bug364677-data.xml^headers^
   bug395533-data.txt
   contextmenu_common.js
   ctxmenu-image.png
-  feed_discovery.html
   head_plain.js
   offlineByDefault.js
   offlineChild.cacheManifest
   offlineChild.cacheManifest^headers^
   offlineChild.html
   offlineChild2.cacheManifest
   offlineChild2.cacheManifest^headers^
   offlineChild2.html
   offlineEvent.cacheManifest
   offlineEvent.cacheManifest^headers^
   offlineEvent.html
   subtst_contextmenu.html
   video.ogg
 
 [test_bug364677.html]
 [test_bug395533.html]
-[test_feed_discovery.html]
-skip-if = e10s
 [test_offlineNotification.html]
 skip-if = buildapp == 'mulet' || e10s # Bug 1066070 - I don't think either popup notifications nor addon install stuff works?
deleted file mode 100644
--- a/browser/base/content/test/general/test_feed_discovery.html
+++ /dev/null
@@ -1,54 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=377611
--->
-<head>
-  <title>Test for feed discovery</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=377611">Mozilla Bug 377611</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-/** Test for Bug 377611 **/
-
-var rv = { tests: null };
-var testCheckInterval = null;
-
-function startTest() {
-  var url = window.location.href.replace(/test_feed_discovery\.html/,
-                                         'feed_discovery.html');
-  SpecialPowers.openDialog(window, [url, '', 'dialog=no,width=10,height=10', rv]);
-  testCheckInterval = window.setInterval(tryIfTestIsFinished, 500);
-}
-
-function tryIfTestIsFinished() {
-  if (rv.tests) {
-    window.clearInterval(testCheckInterval);
-    checkTest();
-  }
-}
-
-function checkTest() {
-  for (var i = 0; i < rv.tests.length; ++ i) {
-    var test = rv.tests[i];
-    ok(test.check, test.message);
-  }
-  SimpleTest.finish();
-}
-
-window.onload = startTest;
-
-SimpleTest.waitForExplicitFinish();
-</script>
-</pre>
-</body>
-</html>
-