mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1184186 - Convert robocop testDeviceSearchEngine to mochitest-chrome; r=mfinkle
This commit is contained in:
parent
2ed3d50a88
commit
ef3a48883d
@ -2,6 +2,7 @@
|
||||
skip-if = os != 'android'
|
||||
support-files =
|
||||
desktopmode_user_agent.sjs
|
||||
devicesearch.xml
|
||||
|
||||
[test_about_logins.html]
|
||||
[test_accounts.html]
|
||||
@ -9,4 +10,5 @@ support-files =
|
||||
[test_app_constants.html]
|
||||
[test_debugger_server.html]
|
||||
[test_desktop_useragent.html]
|
||||
[test_device_search_engine.html]
|
||||
[test_resource_substitutions.html]
|
||||
|
@ -0,0 +1,75 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=861164
|
||||
Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 861164</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.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">
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function search_observer(aSubject, aTopic, aData) {
|
||||
let engine = aSubject.QueryInterface(Ci.nsISearchEngine);
|
||||
info("Observer: " + aData + " for " + engine.name);
|
||||
|
||||
if (aData != "engine-added")
|
||||
return;
|
||||
|
||||
if (engine.name != "Test search engine")
|
||||
return;
|
||||
|
||||
function check_submission(aExpected, aSearchTerm, aType) {
|
||||
is(engine.getSubmission(aSearchTerm, aType).uri.spec, "http://example.com/search" + aExpected, "submission matches");
|
||||
}
|
||||
|
||||
// Force the type and check for the expected URL
|
||||
check_submission("?q=foo", "foo", "text/html");
|
||||
check_submission("/tablet?q=foo", "foo", "application/x-moz-tabletsearch");
|
||||
check_submission("/phone?q=foo", "foo", "application/x-moz-phonesearch");
|
||||
|
||||
// Let the service pick the appropriate type based on the device
|
||||
// and check for expected URL
|
||||
let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
|
||||
if (sysInfo.get("tablet")) {
|
||||
info("Device: tablet");
|
||||
check_submission("/tablet?q=foo", "foo", null);
|
||||
} else {
|
||||
info("Device: phone");
|
||||
check_submission("/phone?q=foo", "foo", null);
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
};
|
||||
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
Services.obs.removeObserver(search_observer, "browser-search-engine-modified");
|
||||
});
|
||||
Services.obs.addObserver(search_observer, "browser-search-engine-modified", false);
|
||||
info("Loading search engine");
|
||||
Services.search.addEngine("http://mochi.test:8888/chrome/mobile/android/tests/browser/chrome/devicesearch.xml", Ci.nsISearchEngine.DATA_XML, null, false);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=861164">Mozilla Bug 861164</a>
|
||||
<br>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1184186">Migrated from Robocop testDeviceSearchEngine</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -113,7 +113,6 @@ skip-if = android_version == "10" || android_version == "18"
|
||||
[testBrowserDiscovery.java]
|
||||
# disabled on 4.3, bug 1158384
|
||||
skip-if = android_version == "18"
|
||||
[testDeviceSearchEngine.java]
|
||||
[testFilePicker.java]
|
||||
[testHistoryService.java]
|
||||
# disabled on 4.3, bug 1116036
|
||||
|
@ -1,11 +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 testDeviceSearchEngine extends JavascriptTest {
|
||||
public testDeviceSearchEngine() {
|
||||
super("testDeviceSearchEngine.js");
|
||||
}
|
||||
}
|
@ -1,55 +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/. */
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
|
||||
function search_observer(aSubject, aTopic, aData) {
|
||||
let engine = aSubject.QueryInterface(Ci.nsISearchEngine);
|
||||
do_print("Observer: " + aData + " for " + engine.name);
|
||||
|
||||
if (aData != "engine-added")
|
||||
return;
|
||||
|
||||
if (engine.name != "Test search engine")
|
||||
return;
|
||||
|
||||
function check_submission(aExpected, aSearchTerm, aType) {
|
||||
do_check_eq(engine.getSubmission(aSearchTerm, aType).uri.spec, "http://example.com/search" + aExpected);
|
||||
}
|
||||
|
||||
// Force the type and check for the expected URL
|
||||
check_submission("?q=foo", "foo", "text/html");
|
||||
check_submission("/tablet?q=foo", "foo", "application/x-moz-tabletsearch");
|
||||
check_submission("/phone?q=foo", "foo", "application/x-moz-phonesearch");
|
||||
|
||||
// Let the service pick the appropriate type based on the device
|
||||
// and check for expected URL
|
||||
let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
|
||||
if (sysInfo.get("tablet")) {
|
||||
do_print("Device: tablet");
|
||||
check_submission("/tablet?q=foo", "foo", null);
|
||||
} else {
|
||||
do_print("Device: phone");
|
||||
check_submission("/phone?q=foo", "foo", null);
|
||||
}
|
||||
|
||||
run_next_test();
|
||||
};
|
||||
|
||||
add_test(function test_default() {
|
||||
do_register_cleanup(function cleanup() {
|
||||
Services.obs.removeObserver(search_observer, "browser-search-engine-modified");
|
||||
});
|
||||
|
||||
Services.obs.addObserver(search_observer, "browser-search-engine-modified", false);
|
||||
|
||||
do_print("Loading search engine");
|
||||
Services.search.addEngine("http://mochi.test:8888/tests/robocop/devicesearch.xml", Ci.nsISearchEngine.DATA_XML, null, false);
|
||||
});
|
||||
|
||||
run_next_test();
|
Loading…
Reference in New Issue
Block a user