summaryrefslogtreecommitdiffstats
path: root/toolkit/components/search/tests/xpcshell/test_engineUpdate.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/components/search/tests/xpcshell/test_engineUpdate.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/search/tests/xpcshell/test_engineUpdate.js')
-rw-r--r--toolkit/components/search/tests/xpcshell/test_engineUpdate.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/toolkit/components/search/tests/xpcshell/test_engineUpdate.js b/toolkit/components/search/tests/xpcshell/test_engineUpdate.js
new file mode 100644
index 000000000..adff41ffb
--- /dev/null
+++ b/toolkit/components/search/tests/xpcshell/test_engineUpdate.js
@@ -0,0 +1,50 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* Test that user-set metadata isn't lost on engine update */
+
+"use strict";
+
+function run_test() {
+ updateAppInfo();
+ useHttpServer();
+
+ run_next_test();
+}
+
+add_task(function* test_engineUpdate() {
+ const KEYWORD = "keyword";
+ const FILENAME = "engine.xml"
+ const TOPIC = "browser-search-engine-modified";
+ const ONE_DAY_IN_MS = 24 * 60 * 60 * 1000;
+
+ yield asyncInit();
+
+ let [engine] = yield addTestEngines([
+ { name: "Test search engine", xmlFileName: FILENAME },
+ ]);
+
+ engine.alias = KEYWORD;
+ Services.search.moveEngine(engine, 0);
+ // can't have an accurate updateURL in the file since we can't know the test
+ // server origin, so manually set it
+ engine.wrappedJSObject._updateURL = gDataUrl + FILENAME;
+
+ yield new Promise(resolve => {
+ Services.obs.addObserver(function obs(subject, topic, data) {
+ if (data == "engine-loaded") {
+ let loadedEngine = subject.QueryInterface(Ci.nsISearchEngine);
+ let rawEngine = loadedEngine.wrappedJSObject;
+ equal(loadedEngine.alias, KEYWORD, "Keyword not cleared by update");
+ equal(rawEngine.getAttr("order"), 1, "Order not cleared by update");
+ Services.obs.removeObserver(obs, TOPIC, false);
+ resolve();
+ }
+ }, TOPIC, false);
+
+ // set last update to 8 days ago, since the default interval is 7, then
+ // trigger an update
+ engine.wrappedJSObject.setAttr("updateexpir", Date.now() - (ONE_DAY_IN_MS * 8));
+ Services.search.QueryInterface(Components.interfaces.nsITimerCallback).notify(null);
+ });
+});