-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into test/schema
- Loading branch information
Showing
24 changed files
with
281 additions
and
75 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
coverage/ | ||
dist/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,8 @@ | |
}, | ||
|
||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"webextensions": true, | ||
"node": true, | ||
}, | ||
|
||
"globals": { | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Community Participation Guidelines | ||
|
||
This repository is governed by Mozilla's code of conduct and etiquette guidelines. | ||
For more details, please read the | ||
[Mozilla Community Participation Guidelines](https://www.mozilla.org/about/governance/policies/participation/). | ||
|
||
## How to Report | ||
|
||
For more information on how to report violations of the Community Participation Guidelines, | ||
please read our '[How to Report](https://www.mozilla.org/about/governance/policies/participation/reporting/)' page. |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
const shell = require("shelljs"); | ||
|
||
/** | ||
* This is to make sure that even if the tests fail on Chrome, | ||
* the tests still run on Firefox, so that it can be seen whether | ||
* Firefox broke too or is unaffected. | ||
*/ | ||
let result = 0; | ||
|
||
console.log(` | ||
Test webextension-polyfill on real browsers | ||
===========================================`); | ||
|
||
// Enable headless mode (currently only used when running on Firefox | ||
// because Chrome doesn't currently support the extensions in headless mode) | ||
process.env.HEADLESS = 1; | ||
|
||
console.log("\nRunning smoketests on Chrome"); | ||
process.env.TEST_BROWSER_TYPE = "chrome"; | ||
result = shell.exec("npm run test-integration:chrome").code || result; | ||
|
||
console.log("\nRunning smoketests on Firefox"); | ||
process.env.TEST_BROWSER_TYPE = "firefox"; | ||
result = shell.exec("npm run test-integration:firefox").code || result; | ||
|
||
process.exit(result); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env node | ||
const shell = require("shelljs"); | ||
|
||
let result = 0; | ||
|
||
console.log(` | ||
Test webextension-polyfill bundled with webpack | ||
===============================================`); | ||
|
||
process.env.TEST_BUNDLED_POLYFILL = "/tmp/webpack-bundle.js"; | ||
result = shell.exec(`webpack --mode production --entry ./test/fixtures/bundle-entrypoint.js --output ${process.env.TEST_BUNDLED_POLYFILL}`).code || | ||
shell.exec("npm run test").code || result; | ||
|
||
console.log(` | ||
Test webextension-polyfill bundled with browserify | ||
==================================================`); | ||
|
||
process.env.TEST_BUNDLED_POLYFILL = "/tmp/browserify-bundle.js"; | ||
result = shell.exec(`browserify test/fixtures/bundle-entrypoint.js > ${process.env.TEST_BUNDLED_POLYFILL}`).code || | ||
shell.exec("npm run test").code || result; | ||
|
||
process.exit(result); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"node": false, | ||
"webextensions": true, | ||
}, | ||
"globals": { | ||
// Allow the `module` global, but not the `require(…)` function | ||
"module": false, | ||
}, | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
let onDevToolsPageLoaded = new Promise(resolve => { | ||
const listener = () => { | ||
browser.runtime.onConnect.removeListener(listener); | ||
resolve(); | ||
}; | ||
browser.runtime.onConnect.addListener(listener); | ||
}); | ||
|
||
browser.runtime.onMessage.addListener(async msg => { | ||
await onDevToolsPageLoaded; | ||
return browser.runtime.sendMessage(msg); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
test("devtools.inspectedWindow.eval resolved with an error result", { | ||
timeout: 5000, | ||
}, async (t) => { | ||
const {evalResult} = await browser.runtime.sendMessage({ | ||
apiMethod: "devtools.inspectedWindow.eval", | ||
params: ["throw new Error('fake error');"], | ||
}); | ||
|
||
t.ok(Array.isArray(evalResult), "devtools.inspectedWindow.eval should resolve to an array"); | ||
|
||
t.equal(evalResult[0], navigator.userAgent.includes("Firefox/") ? undefined : null, | ||
"the first element should be null (on chrome) or undefined (on firefox)"); | ||
|
||
t.ok(evalResult[1].isException, "the second element should represent an exception"); | ||
t.ok(evalResult[1].value && evalResult[1].value.includes("fake error"), | ||
"the second element value property should include the expected error message"); | ||
}); | ||
|
||
test("devtools.inspectedWindow.eval resolved without an error result", { | ||
timeout: 5000, | ||
}, async (t) => { | ||
const {evalResult} = await browser.runtime.sendMessage({ | ||
apiMethod: "devtools.inspectedWindow.eval", | ||
params: ["[document.documentElement.localName]"], | ||
}); | ||
|
||
t.ok(Array.isArray(evalResult), "devtools.inspectedWindow.eval should resolve to an array"); | ||
|
||
if (navigator.userAgent.includes("Firefox/")) { | ||
t.deepEqual(evalResult, [["html"], undefined], "got the expected values in the array"); | ||
} else { | ||
t.deepEqual(evalResult, [["html"]], "got the expected values in the array"); | ||
} | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="browser-polyfill.js"></script> | ||
<script src="devtools_page.js"></script> | ||
</head> | ||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
console.log("devtools page loaded"); | ||
|
||
browser.runtime.onMessage.addListener(async msg => { | ||
switch (msg.apiMethod) { | ||
case "devtools.inspectedWindow.eval": { | ||
const evalResult = await browser.devtools.inspectedWindow.eval(...msg.params); | ||
return {evalResult}; | ||
} | ||
} | ||
|
||
throw new Error(`devtools_page received an unxpected message: ${msg}`); | ||
}); | ||
|
||
browser.runtime.connect({name: "devtools_page"}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "test-extension-devtools-api", | ||
"version": "0.1", | ||
"description": "test-extension-devtools-api", | ||
"content_scripts": [ | ||
{ | ||
"matches": [ | ||
"http://localhost/*" | ||
], | ||
"js": [ | ||
"browser-polyfill.js", | ||
"tape.js", | ||
"content.js" | ||
], | ||
"run_at": "document_end" | ||
} | ||
], | ||
"permissions": [], | ||
"background": { | ||
"scripts": [ | ||
"browser-polyfill.js", | ||
"background.js" | ||
] | ||
}, | ||
"devtools_page": "devtools_page.html" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<!DOCTYPE> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Browser Polyfill Test Page</title> | ||
|
This file contains 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
Oops, something went wrong.