Bug 1277524 - Add a WebExtension test that moz-extension is considered a trustworthy origin. r=kmag

MozReview-Commit-ID: 1LLNWwIU90

--HG--
extra : rebase_source : 759718dea882e10ce1307fca1b9d415c8f10c067
extra : histedit_source : 1f8fd6a084d0314e5a264b73164bcf2d35127c6b
This commit is contained in:
Johann Hofmann 2016-06-03 12:26:28 +02:00
Родитель 0e04940e1a
Коммит 03def5b207
17 изменённых файлов: 82 добавлений и 30 удалений

Просмотреть файл

@ -1,5 +1,6 @@
[DEFAULT] [DEFAULT]
support-files = support-files =
chrome_head.js
head.js head.js
file_download.html file_download.html
file_download.txt file_download.txt
@ -18,6 +19,7 @@ skip-if = (toolkit == 'android') # android doesn't have devtools
skip-if = os == "android" # native messaging is not supported on android skip-if = os == "android" # native messaging is not supported on android
[test_chrome_ext_contentscript_unrecognizedprop_warning.html] [test_chrome_ext_contentscript_unrecognizedprop_warning.html]
skip-if = (os == 'android') # browser.tabs is undefined. Bug 1258975 on android. skip-if = (os == 'android') # browser.tabs is undefined. Bug 1258975 on android.
[test_chrome_ext_trustworthy_origin.html]
[test_chrome_ext_webnavigation_resolved_urls.html] [test_chrome_ext_webnavigation_resolved_urls.html]
skip-if = (os == 'android') # browser.tabs is undefined. Bug 1258975 on android. skip-if = (os == 'android') # browser.tabs is undefined. Bug 1258975 on android.
[test_chrome_native_messaging_paths.html] [test_chrome_native_messaging_paths.html]

Просмотреть файл

@ -0,0 +1,12 @@
"use strict";
const {
classes: Cc,
interfaces: Ci,
utils: Cu,
results: Cr,
} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");

Просмотреть файл

@ -5,6 +5,7 @@
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/>
</head> </head>
@ -12,9 +13,6 @@
<script type="text/javascript"> <script type="text/javascript">
"use strict"; "use strict";
const {
utils: Cu,
} = Components;
Cu.import("resource://devtools/client/framework/ToolboxProcess.jsm"); Cu.import("resource://devtools/client/framework/ToolboxProcess.jsm");

Просмотреть файл

@ -5,6 +5,7 @@
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/>
</head> </head>
@ -13,9 +14,6 @@
<script type="text/javascript"> <script type="text/javascript">
"use strict"; "use strict";
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://testing-common/TestUtils.jsm"); Cu.import("resource://testing-common/TestUtils.jsm");
/* eslint-disable mozilla/balanced-listeners */ /* eslint-disable mozilla/balanced-listeners */

Просмотреть файл

@ -5,6 +5,7 @@
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/>
</head> </head>

Просмотреть файл

@ -5,6 +5,7 @@
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/>
</head> </head>
@ -13,18 +14,12 @@
<script type="text/javascript"> <script type="text/javascript">
"use strict"; "use strict";
const {
interfaces: Ci,
utils: Cu,
} = Components;
/* global OS */ /* global OS */
Cu.import("resource://gre/modules/osfile.jsm"); Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm"); Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/Downloads.jsm"); Cu.import("resource://gre/modules/Downloads.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const WINDOWS = (AppConstants.platform == "win"); const WINDOWS = (AppConstants.platform == "win");

Просмотреть файл

@ -5,6 +5,7 @@
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/>
</head> </head>
@ -13,12 +14,6 @@
<script type="text/javascript"> <script type="text/javascript">
"use strict"; "use strict";
const {
interfaces: Ci,
utils: Cu,
} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/Downloads.jsm"); Cu.import("resource://gre/modules/Downloads.jsm");

Просмотреть файл

@ -5,6 +5,7 @@
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/>
</head> </head>
@ -13,12 +14,6 @@
<script type="text/javascript"> <script type="text/javascript">
"use strict"; "use strict";
const {
interfaces: Ci,
utils: Cu,
} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/Downloads.jsm"); Cu.import("resource://gre/modules/Downloads.jsm");

Просмотреть файл

@ -5,6 +5,7 @@
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/>
</head> </head>

Просмотреть файл

@ -5,6 +5,7 @@
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/>
</head> </head>
@ -15,12 +16,9 @@
/* globals OS */ /* globals OS */
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/AppConstants.jsm"); Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/osfile.jsm"); Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/Services.jsm");
let {Subprocess, SubprocessImpl} = Cu.import("resource://gre/modules/Subprocess.jsm"); let {Subprocess, SubprocessImpl} = Cu.import("resource://gre/modules/Subprocess.jsm");
Components.utils.import("resource://gre/modules/Task.jsm"); Components.utils.import("resource://gre/modules/Task.jsm");

Просмотреть файл

@ -0,0 +1,54 @@
<!DOCTYPE HTML>
<html>
<head>
<title>WebExtension test</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="text/javascript">
"use strict";
/**
* This test is asserting that moz-extension: URLs are recognized as trustworthy local origins
*/
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "gContentSecurityManager",
"@mozilla.org/contentsecuritymanager;1",
"nsIContentSecurityManager");
add_task(function* () {
function backgroundScript() {
browser.test.sendMessage("ready", browser.runtime.getURL("/test.html"));
}
let extensionData = {
background: "(" + backgroundScript.toString() + ")()",
manifest: {},
files: {
"test.html": `<html><head></head><body></body></html>`,
},
};
let extension = ExtensionTestUtils.loadExtension(extensionData);
yield extension.startup();
let url = yield extension.awaitMessage("ready");
let uri = NetUtil.newURI(url);
let principal = Services.scriptSecurityManager.getCodebasePrincipal(uri);
is(gContentSecurityManager.isOriginPotentiallyTrustworthy(principal), true);
yield extension.unload();
});
</script>
</body>
</html>

Просмотреть файл

@ -5,6 +5,7 @@
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/>
</head> </head>

Просмотреть файл

@ -5,6 +5,7 @@
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/>
</head> </head>
@ -13,13 +14,10 @@
<script type="text/javascript"> <script type="text/javascript">
"use strict"; "use strict";
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
/* global OS */ /* global OS */
Cu.import("resource://gre/modules/osfile.jsm"); Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm"); Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/Services.jsm");
// Test that the default paths searched for native host manifests // Test that the default paths searched for native host manifests
// are the ones we expect. // are the ones we expect.

Просмотреть файл

@ -5,6 +5,7 @@
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head> </head>

Просмотреть файл

@ -5,6 +5,7 @@
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head> </head>

Просмотреть файл

@ -6,6 +6,7 @@
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head> </head>

Просмотреть файл

@ -5,6 +5,7 @@
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script> <script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head> </head>