Created
April 23, 2019 10:30
-
-
Save daleharvey/dd6282dc6b4cf4a7aa710206c9841048 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const glob = require('glob'); | |
const fs = require('fs'); | |
const fetch = require('node-fetch'); | |
const GECKO_PATH = "/Users/dale/src/gecko"; | |
const EXTENSIONS_PATH = "browser/components/search/extensions"; | |
async function testUrl(url) { | |
if (!url || !/https/.test(url)) { | |
return true; | |
} | |
try { | |
let result = await fetch(url, {timeout: 50000}); | |
if (!/https/.test(result.url)) { | |
console.log(`failed: ${url}`); | |
} | |
} catch (ex) { | |
console.log(`failed: ${url}`); | |
return false; | |
} | |
return true; | |
} | |
(async function test() { | |
let path = `${GECKO_PATH}/${EXTENSIONS_PATH}/**/manifest.json`; | |
let files = glob.sync(path).sort(); | |
for (const file of files) { | |
let rawdata = fs.readFileSync(file); | |
let manifest = JSON.parse(rawdata); | |
let {search_url, suggest_url, search_form, search_url_get_params} = | |
manifest.chrome_settings_overrides.search_provider; | |
if (!(await testUrl(search_url + "?" + search_url_get_params)) || | |
!(await testUrl(suggest_url)) || | |
!(await testUrl(search_form))) { | |
console.error(`${file} failed`); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment