Skip to content

Commit

Permalink
test: Added minimal integration test as smoke test for importing poly…
Browse files Browse the repository at this point in the history
…fill as es6 module
  • Loading branch information
rpl committed Dec 11, 2019
1 parent 9af4239 commit cdfd308
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/fixtures/import-as-es6-extension/background.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
</head>
<body>
<script type='module' src='browser-polyfill.js'></script>
<script type='module' src='background.js'></script>
</body>
</html>
3 changes: 3 additions & 0 deletions test/fixtures/import-as-es6-extension/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
browser.runtime.onMessage.addListener(async (msg, sender) => {
return {bgReceived: msg};
});
5 changes: 5 additions & 0 deletions test/fixtures/import-as-es6-extension/content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test("Test browser.runtime.onMessage on polyfill loaded as es6 module", async (t) => {
const msg = "send-message-to-background-page";
const res = await browser.runtime.sendMessage(msg);
t.deepEqual(res, {bgReceived: msg}, "Got the expected reply");
});
22 changes: 22 additions & 0 deletions test/fixtures/import-as-es6-extension/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"manifest_version": 2,
"name": "test-import-as-es6-module",
"version": "0.1",
"description": "test-import-as-es6-module",
"content_scripts": [
{
"matches": [
"http://localhost/*"
],
"js": [
"browser-polyfill.js",
"tape.js",
"content.js"
]
}
],
"permissions": [],
"background": {
"page": "background.html"
}
}
5 changes: 5 additions & 0 deletions test/integration/test-extensions-in-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

const {defineExtensionTests} = require("./setup");

defineExtensionTests({
description: "polyfill imported as an ES6 module",
extensions: ["import-as-es6-extension"],
});

defineExtensionTests({
description: "browser.runtime.onMessage/sendMessage",
extensions: ["runtime-messaging-extension"],
Expand Down

0 comments on commit cdfd308

Please sign in to comment.