Created
April 22, 2019 15:17
-
-
Save daleharvey/79c831427d46fd04f4194dcbe0924ec6 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 { | |
//console.log(`testing ${url}`); | |
await fetch(url, {timeout: 50000}); | |
return true; | |
} catch (ex) { | |
console.log(`failed: ${url}`); | |
return false; | |
} | |
} | |
(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} = | |
manifest.chrome_settings_overrides.search_provider; | |
if (!(await testUrl(search_url)) || | |
!(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