summaryrefslogtreecommitdiffstats
path: root/browser/components/search/test/browser_google_behavior.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-03 06:00:38 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-03 06:00:38 -0500
commit8148615da179fdd60f19018e13b4e94b95609cc6 (patch)
tree771fccdd99fa3adf35fdd2c81d8197b415a89b91 /browser/components/search/test/browser_google_behavior.js
parent494802c1be7888025b95260d23db187467d2b9dd (diff)
downloadUXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar
UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.gz
UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.lz
UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.xz
UXP-8148615da179fdd60f19018e13b4e94b95609cc6.zip
Remove browser tests - Part 1: The Tests (except for experiments)
Diffstat (limited to 'browser/components/search/test/browser_google_behavior.js')
-rw-r--r--browser/components/search/test/browser_google_behavior.js165
1 files changed, 0 insertions, 165 deletions
diff --git a/browser/components/search/test/browser_google_behavior.js b/browser/components/search/test/browser_google_behavior.js
deleted file mode 100644
index 55405bb29..000000000
--- a/browser/components/search/test/browser_google_behavior.js
+++ /dev/null
@@ -1,165 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * Test Google search plugin URLs
- */
-
-"use strict";
-
-function test() {
- let engine = Services.search.getEngineByName("Google");
- ok(engine, "Google is installed");
-
- let previouslySelectedEngine = Services.search.currentEngine;
- Services.search.currentEngine = engine;
- engine.alias = "g";
-
- let base = "https://www.google.com/search?q=foo&ie=utf-8&oe=utf-8&client=firefox-b";
- let keywordBase = base + "-ab";
-
- let url;
-
- // Test search URLs (including purposes).
- url = engine.getSubmission("foo").uri.spec;
- is(url, base, "Check search URL for 'foo'");
-
- waitForExplicitFinish();
-
- var gCurrTest;
- var gTests = [
- {
- name: "context menu search",
- searchURL: base,
- run: function () {
- // Simulate a contextmenu search
- // FIXME: This is a bit "low-level"...
- BrowserSearch.loadSearch("foo", false, "contextmenu");
- }
- },
- {
- name: "keyword search",
- searchURL: keywordBase,
- run: function () {
- gURLBar.value = "? foo";
- gURLBar.focus();
- EventUtils.synthesizeKey("VK_RETURN", {});
- }
- },
- {
- name: "keyword search",
- searchURL: keywordBase,
- run: function () {
- gURLBar.value = "g foo";
- gURLBar.focus();
- EventUtils.synthesizeKey("VK_RETURN", {});
- }
- },
- {
- name: "search bar search",
- searchURL: base,
- run: function () {
- let sb = BrowserSearch.searchBar;
- sb.focus();
- sb.value = "foo";
- registerCleanupFunction(function () {
- sb.value = "";
- });
- EventUtils.synthesizeKey("VK_RETURN", {});
- }
- },
- {
- name: "new tab search",
- searchURL: base,
- run: function () {
- function doSearch(doc) {
- // Re-add the listener, and perform a search
- gBrowser.addProgressListener(listener);
- doc.getElementById("newtab-search-text").value = "foo";
- doc.getElementById("newtab-search-submit").click();
- }
-
- // load about:newtab, but remove the listener first so it doesn't
- // get in the way
- gBrowser.removeProgressListener(listener);
- gBrowser.loadURI("about:newtab");
- info("Waiting for about:newtab load");
- tab.linkedBrowser.addEventListener("load", function load(event) {
- if (event.originalTarget != tab.linkedBrowser.contentDocument ||
- event.target.location.href == "about:blank") {
- info("skipping spurious load event");
- return;
- }
- tab.linkedBrowser.removeEventListener("load", load, true);
-
- // Observe page setup
- let win = gBrowser.contentWindow;
- if (win.gSearch.currentEngineName ==
- Services.search.currentEngine.name) {
- doSearch(win.document);
- }
- else {
- info("Waiting for newtab search init");
- win.addEventListener("ContentSearchService", function done(event) {
- info("Got newtab search event " + event.detail.type);
- if (event.detail.type == "State") {
- win.removeEventListener("ContentSearchService", done);
- // Let gSearch respond to the event before continuing.
- executeSoon(() => doSearch(win.document));
- }
- });
- }
- }, true);
- }
- }
- ];
-
- function nextTest() {
- if (gTests.length) {
- gCurrTest = gTests.shift();
- info("Running : " + gCurrTest.name);
- executeSoon(gCurrTest.run);
- } else {
- finish();
- }
- }
-
- let tab = gBrowser.selectedTab = gBrowser.addTab();
-
- let listener = {
- onStateChange: function onStateChange(webProgress, req, flags, status) {
- info("onStateChange");
- // Only care about top-level document starts
- let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
- Ci.nsIWebProgressListener.STATE_START;
- if (!(flags & docStart) || !webProgress.isTopLevel)
- return;
-
- if (req.originalURI.spec == "about:blank")
- return;
-
- info("received document start");
-
- ok(req instanceof Ci.nsIChannel, "req is a channel");
- is(req.originalURI.spec, gCurrTest.searchURL, "search URL was loaded");
- info("Actual URI: " + req.URI.spec);
-
- req.cancel(Components.results.NS_ERROR_FAILURE);
-
- executeSoon(nextTest);
- }
- }
-
- registerCleanupFunction(function () {
- engine.alias = undefined;
- gBrowser.removeProgressListener(listener);
- gBrowser.removeTab(tab);
- Services.search.currentEngine = previouslySelectedEngine;
- });
-
- tab.linkedBrowser.addEventListener("load", function load() {
- tab.linkedBrowser.removeEventListener("load", load, true);
- gBrowser.addProgressListener(listener);
- nextTest();
- }, true);
-}