forked from mirrors/gecko-dev
		
	Running eslint with --fix didn't fix many of the issues. The majority here had to be fixed by hand but a significant majority of the issues were related to a few files that I was able to use find-and-replace with. I regret not making this in to separate commits of the hand-fixes and the fixes from --fix but I don't recall --fix fixing any of the issues. MozReview-Commit-ID: ANyg2qfo3Qx --HG-- extra : rebase_source : 61d2aa91bf9474af3d72a5dea41b25dca442c1b7
		
			
				
	
	
		
			82 lines
		
	
	
	
		
			2.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			82 lines
		
	
	
	
		
			2.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/* 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");
 | 
						|
}
 |