summaryrefslogtreecommitdiffstats
path: root/mobile/android/tests/browser/robocop/testFindInPage.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2019-04-23 15:32:23 -0400
committerMatt A. Tobin <email@mattatobin.com>2019-04-23 15:32:23 -0400
commitabe80cc31d5a40ebed743085011fbcda0c1a9a10 (patch)
treefb3762f06b84745b182af281abb107b95a9fcf01 /mobile/android/tests/browser/robocop/testFindInPage.js
parent63295d0087eb58a6eb34cad324c4c53d1b220491 (diff)
downloadUXP-abe80cc31d5a40ebed743085011fbcda0c1a9a10.tar
UXP-abe80cc31d5a40ebed743085011fbcda0c1a9a10.tar.gz
UXP-abe80cc31d5a40ebed743085011fbcda0c1a9a10.tar.lz
UXP-abe80cc31d5a40ebed743085011fbcda0c1a9a10.tar.xz
UXP-abe80cc31d5a40ebed743085011fbcda0c1a9a10.zip
Issue #1053 - Drop support Android and remove Fennec - Part 1a: Remove mobile/android
Diffstat (limited to 'mobile/android/tests/browser/robocop/testFindInPage.js')
-rw-r--r--mobile/android/tests/browser/robocop/testFindInPage.js89
1 files changed, 0 insertions, 89 deletions
diff --git a/mobile/android/tests/browser/robocop/testFindInPage.js b/mobile/android/tests/browser/robocop/testFindInPage.js
deleted file mode 100644
index 485ae5e4e..000000000
--- a/mobile/android/tests/browser/robocop/testFindInPage.js
+++ /dev/null
@@ -1,89 +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/. */
-
-"use strict";
-
-var Cu = Components.utils;
-
-Cu.import("resource://gre/modules/Messaging.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-
-const TEST_URL = "http://mochi.test:8888/tests/robocop/robocop_text_page.html";
-
-function promiseBrowserEvent(browser, eventType) {
- return new Promise((resolve) => {
- function handle(event) {
- 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 openTabWithUrl(url) {
- do_print("Going to open " + url);
- let browserApp = Services.wm.getMostRecentWindow("navigator:browser").BrowserApp;
- let browser = browserApp.addTab(url, { selected: true, parentId: browserApp.selectedTab.id }).browser;
-
- return promiseBrowserEvent(browser, "load")
- .then(() => { return browser; });
-}
-
-function findInPage(browser, text, nrOfMatches) {
- let repaintPromise = promiseBrowserEvent(browser, "MozAfterPaint");
- do_print("Send findInPageMessage: " + text + " nth: " + nrOfMatches);
- Messaging.sendRequest({ type: "Test:FindInPage", text: text, nrOfMatches: nrOfMatches });
- return repaintPromise;
-}
-
-function closeFindInPage(browser) {
- let repaintPromise = promiseBrowserEvent(browser, "MozAfterPaint");
- do_print("Send closeFindInPageMessage");
- Messaging.sendRequest({ type: "Test:CloseFindInPage" });
- return repaintPromise;
-}
-
-function assertSelection(document, expectedSelection = false, expectedAnchorText = false) {
- let sel = document.getSelection();
- if (!expectedSelection) {
- do_print("Assert empty selection");
- do_check_eq(sel.toString(), "");
- } else {
- do_print("Assert selection to be " + expectedSelection);
- do_check_eq(sel.toString(), expectedSelection);
- }
- if (expectedAnchorText) {
- do_print("Assert anchor text to be " + expectedAnchorText);
- do_check_eq(sel.anchorNode.textContent, expectedAnchorText);
- }
-}
-
-add_task(function* testFindInPage() {
- let browser = yield openTabWithUrl(TEST_URL);
- let document = browser.contentDocument;
-
- yield findInPage(browser, "Robocoop", 1);
- assertSelection(document);
-
- yield closeFindInPage(browser);
- assertSelection(document);
-
- yield findInPage(browser, "Robocop", 1);
- assertSelection(document, "Robocop", " Robocop 1 ");
-
- yield closeFindInPage(browser);
- assertSelection(document);
-
- yield findInPage(browser, "Robocop", 3);
- assertSelection(document, "Robocop", " Robocop 3 ");
-
- yield closeFindInPage(browser);
- assertSelection(document);
-});
-
-run_next_test();