/
browser_amazon.js
82 lines (73 loc) · 2.41 KB
/
browser_amazon.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/*
* Test Amazon search plugin URLs
*/
"use strict";
const BROWSER_SEARCH_PREF = "browser.search.";
function test() {
let engine = Services.search.getEngineByName("Amazon.com");
ok(engine, "Amazon.com");
let base = "https://www.amazon.com/exec/obidos/external-search/?field-keywords=foo&ie=UTF-8&mode=blended&tag=mozilla-20&sourceid=Mozilla-search";
let url;
// Test search URLs (including purposes).
url = engine.getSubmission("foo").uri.spec;
is(url, base, "Check search URL for 'foo'");
// Check search suggestion URL.
url = engine.getSubmission("foo", "application/x-suggestions+json").uri.spec;
is(url, "https://completion.amazon.com/search/complete?q=foo&search-alias=aps&mkt=1", "Check search suggestion URL for 'foo'");
// Check all other engine properties.
const EXPECTED_ENGINE = {
name: "Amazon.com",
alias: null,
description: "Amazon.com Search",
searchForm: "https://www.amazon.com/exec/obidos/external-search/?field-keywords=&ie=UTF-8&mode=blended&tag=mozilla-20&sourceid=Mozilla-search",
hidden: false,
wrappedJSObject: {
queryCharset: "UTF-8",
"_iconURL": "resource://search-plugins/images/amazon.ico",
_urls: [
{
type: "application/x-suggestions+json",
method: "GET",
template: "https://completion.amazon.com/search/complete?q={searchTerms}&search-alias=aps&mkt=1",
params: "",
},
{
type: "text/html",
method: "GET",
template: "https://www.amazon.com/exec/obidos/external-search/",
params: [
{
name: "field-keywords",
value: "{searchTerms}",
purpose: undefined,
},
{
name: "ie",
value: "{inputEncoding}",
purpose: undefined,
},
{
name: "mode",
value: "blended",
purpose: undefined,
},
{
name: "tag",
value: "mozilla-20",
purpose: undefined,
},
{
name: "sourceid",
value: "Mozilla-search",
purpose: undefined,
},
],
mozparams: {},
},
],
},
};
isSubObjectOf(EXPECTED_ENGINE, engine, "Amazon");
}