Bug 1184186 - Convert robocop testReaderView to mochitest-chrome; r=margaret
authorGeoff Brown <gbrown@mozilla.com>
Thu, 06 Aug 2015 07:27:47 -0600
changeset 288187 07097d4a43b69c0c0a882c9ee797bc57849cced3
parent 288186 81ed032662fac244762293cfb805439d7217b287
child 288188 61612437cafc2c2dcf247f515644b78eb4a97623
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs1184186
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1184186 - Convert robocop testReaderView to mochitest-chrome; r=margaret
mobile/android/tests/browser/chrome/basic_article.html
mobile/android/tests/browser/chrome/chrome.ini
mobile/android/tests/browser/chrome/test_reader_view.html
mobile/android/tests/browser/robocop/robocop.ini
mobile/android/tests/browser/robocop/testReaderView.java
mobile/android/tests/browser/robocop/testReaderView.js
new file mode 100644
--- /dev/null
+++ b/mobile/android/tests/browser/chrome/basic_article.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Article title</title>
+<meta name="description" content="This is the article description." />
+</head>
+<body>
+<header>Site header</header>
+<div>
+<h1>Article title</h1>
+<h2 class="author">by Jane Doe</h2>
+<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est.</p>
+<p>Vivamus fermentum semper porta. Nunc diam velit, adipiscing ut tristique vitae, sagittis vel odio. Maecenas convallis ullamcorper ultricies. Curabitur ornare, ligula semper consectetur sagittis, nisi diam iaculis velit, id fringilla sem nunc vel mi. Nam dictum, odio nec pretium volutpat, arcu ante placerat erat, non tristique elit urna et turpis. Quisque mi metus, ornare sit amet fermentum et, tincidunt et orci. Fusce eget orci a orci congue vestibulum. Ut dolor diam, elementum et vestibulum eu, porttitor vel elit. Curabitur venenatis pulvinar tellus gravida ornare. Sed et erat faucibus nunc euismod ultricies ut id justo. Nullam cursus suscipit nisi, et ultrices justo sodales nec. Fusce venenatis facilisis lectus ac semper. Aliquam at massa ipsum. Quisque bibendum purus convallis nulla ultrices ultricies. Nullam aliquam, mi eu aliquam tincidunt, purus velit laoreet tortor, viverra pretium nisi quam vitae mi. Fusce vel volutpat elit. Nam sagittis nisi dui.</p>
+</div>
+</body>
+</html>
--- a/mobile/android/tests/browser/chrome/chrome.ini
+++ b/mobile/android/tests/browser/chrome/chrome.ini
@@ -1,11 +1,12 @@
 [DEFAULT]
 skip-if = os != 'android'
 support-files =
+  basic_article.html
   desktopmode_user_agent.sjs
   devicesearch.xml
   video_controls.html
 
 [test_about_logins.html]
 [test_accounts.html]
 [test_android_log.html]
 [test_app_constants.html]
@@ -13,9 +14,10 @@ support-files =
 [test_desktop_useragent.html]
 [test_device_search_engine.html]
 [test_home_provider.html]
 [test_java_addons.html]
 [test_jni.html]
 [test_migrate_ui.html]
 [test_network_manager.html]
 [test_offline_page.html]
+[test_reader_view.html]
 [test_resource_substitutions.html]
new file mode 100644
--- /dev/null
+++ b/mobile/android/tests/browser/chrome/test_reader_view.html
@@ -0,0 +1,83 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1158885
+Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 1158885</title>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script type="application/javascript;version=1.7">
+
+  const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+
+  Cu.import("resource://gre/modules/Services.jsm");
+
+  function promiseBrowserEvent(browser, eventType) {
+    return new Promise((resolve) => {
+      function handle(event) {
+        // Since we'll be redirecting, don't make assumptions about the given URL and the loaded URL
+        if (event.target != browser.contentDocument || event.target.location.href == "about:blank") {
+          info("Skipping spurious '" + eventType + "' event" + " for " + event.target.location.href);
+          return;
+        }
+        info("Received event " + eventType + " from browser");
+        browser.removeEventListener(eventType, handle, true);
+        resolve(event);
+      }
+
+      browser.addEventListener(eventType, handle, true);
+      info("Now waiting for " + eventType + " event from browser");
+    });
+  }
+
+  function promiseNotification(topic) {
+    return new Promise((resolve, reject) => {
+      function observe(subject, topic, data) {
+        Services.obs.removeObserver(observe, topic);
+        resolve();
+      }
+      Services.obs.addObserver(observe, topic, false);
+    });
+  }
+
+  add_task(function* test_reader_view_visibility() {
+    let gWin = Services.wm.getMostRecentWindow("navigator:browser");
+    let BrowserApp = gWin.BrowserApp;
+
+    let url = "http://mochi.test:8888/chrome/mobile/android/tests/browser/chrome/basic_article.html";
+    let browser = BrowserApp.addTab("about:reader?url=" + url).browser;
+
+    SimpleTest.registerCleanupFunction(function() {
+      BrowserApp.closeTab(BrowserApp.getTabForBrowser(browser));
+    });
+
+    yield promiseBrowserEvent(browser, "load");
+
+    let doc = browser.contentDocument;
+    let title = doc.getElementById("reader-title");
+
+    // We need to wait for reader content to appear because AboutReader.jsm
+    // asynchronously fetches the content after about:reader loads.
+    yield promiseNotification("AboutReader:Ready");
+    is(title.textContent, "Article title", "found expected content");
+  });
+
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1158885">Mozilla Bug 1158885</a>
+<br>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1184186">Migrated from Robocop testReaderView</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
--- a/mobile/android/tests/browser/robocop/robocop.ini
+++ b/mobile/android/tests/browser/robocop/robocop.ini
@@ -116,17 +116,16 @@ skip-if = android_version == "18"
 [testHistoryService.java]
 # disabled on 4.3, bug 1116036
 skip-if = android_version == "18"
 # [testMozPay.java] # see bug 945675
 [testOrderedBroadcast.java]
 [testOSLocale.java]
 # disabled on 2.3 and 4.3: Bug 1124494
 skip-if = android_version == "10" || android_version == "18"
-[testReaderView.java]
 [testReadingListCache.java]
 [testRestrictedProfiles.java]
 [testRestrictions.java]
 [testSessionFormData.java]
 [testSharedPreferences.java]
 [testSimpleDiscovery.java]
 [testTrackingProtection.java]
 # disabled on 4.3, bug 1158363
deleted file mode 100644
--- a/mobile/android/tests/browser/robocop/testReaderView.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-package org.mozilla.gecko.tests;
-
-
-public class testReaderView extends JavascriptTest {
-    public testReaderView() {
-        super("testReaderView.js");
-    }
-}
deleted file mode 100644
--- a/mobile/android/tests/browser/robocop/testReaderView.js
+++ /dev/null
@@ -1,60 +0,0 @@
-// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
-
-Cu.import("resource://gre/modules/Services.jsm");
-
-function promiseBrowserEvent(browser, eventType) {
-  return new Promise((resolve) => {
-    function handle(event) {
-      // Since we'll be redirecting, don't make assumptions about the given URL and the loaded URL
-      if (event.target != browser.contentDocument || event.target.location.href == "about:blank") {
-        do_print("Skipping spurious '" + eventType + "' event" + " for " + event.target.location.href);
-        return;
-      }
-      do_print("Received event " + eventType + " from browser");
-      browser.removeEventListener(eventType, handle, true);
-      resolve(event);
-    }
-
-    browser.addEventListener(eventType, handle, true);
-    do_print("Now waiting for " + eventType + " event from browser");
-  });
-}
-
-function promiseNotification(topic) {
-  return new Promise((resolve, reject) => {
-    function observe(subject, topic, data) {
-      Services.obs.removeObserver(observe, topic);
-      resolve();
-    }
-    Services.obs.addObserver(observe, topic, false);
-  });
-}
-
-add_task(function* test_reader_view_visibility() {
-  let gWin = Services.wm.getMostRecentWindow("navigator:browser");
-  let BrowserApp = gWin.BrowserApp;
-
-  let url = "http://mochi.test:8888/tests/robocop/reader_mode_pages/basic_article.html";
-  let browser = BrowserApp.addTab("about:reader?url=" + url).browser;
-
-  yield promiseBrowserEvent(browser, "load");
-
-  do_register_cleanup(function cleanup() {
-    BrowserApp.closeTab(BrowserApp.getTabForBrowser(browser));
-  });
-
-  let doc = browser.contentDocument;
-  let title = doc.getElementById("reader-title");
-
-  // We need to wait for reader content to appear because AboutReader.jsm
-  // asynchronously fetches the content after about:reader loads.
-  yield promiseNotification("AboutReader:Ready");
-  do_check_eq(title.textContent, "Article title");
-});
-
-run_next_test();