mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1199473 - [webext] Fix wrong parameter name for browser.extension.getURL (r=gabor)
This commit is contained in:
parent
03392338c3
commit
762cb0c0cd
@ -60,7 +60,7 @@ var api = context => { return {
|
||||
return context.extension.getManifest();
|
||||
},
|
||||
|
||||
getURL: function(path) {
|
||||
getURL: function(url) {
|
||||
return context.extension.baseURI.resolve(url);
|
||||
},
|
||||
|
||||
@ -84,7 +84,7 @@ var api = context => { return {
|
||||
},
|
||||
|
||||
extension: {
|
||||
getURL: function(path) {
|
||||
getURL: function(url) {
|
||||
return context.extension.baseURI.resolve(url);
|
||||
},
|
||||
|
||||
|
8
toolkit/components/extensions/test/mochitest/head.js
Normal file
8
toolkit/components/extensions/test/mochitest/head.js
Normal file
@ -0,0 +1,8 @@
|
||||
function waitForLoad(win) {
|
||||
return new Promise(resolve => {
|
||||
win.addEventListener("load", function listener() {
|
||||
win.removeEventListener("load", listener, true);
|
||||
resolve();
|
||||
}, true);
|
||||
});
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
[DEFAULT]
|
||||
skip-if = os == 'android' || buildapp == 'b2g' || buildapp == 'mulet' || os == 'mac'
|
||||
support-files =
|
||||
head.js
|
||||
file_WebRequest_page1.html
|
||||
file_WebRequest_page2.html
|
||||
file_image_good.png
|
||||
@ -16,6 +17,7 @@ support-files =
|
||||
file_contentscript_page1.html
|
||||
|
||||
[test_simple_extensions.html]
|
||||
[test_ext_geturl.html]
|
||||
[test_extension_contentscript.html]
|
||||
[test_extension_webrequest.html]
|
||||
[test_generate_extension.html]
|
||||
|
@ -0,0 +1,76 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>WebExtension test</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<script type="text/javascript" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="application/javascript;version=1.8">
|
||||
|
||||
function backgroundScript() {
|
||||
browser.runtime.onMessage.addListener(([url1, url2]) => {
|
||||
var url3 = browser.runtime.getURL("test_file.html");
|
||||
var url4 = browser.extension.getURL("test_file.html");
|
||||
|
||||
browser.test.assertTrue(url1 !== undefined, "url1 defined");
|
||||
|
||||
browser.test.assertTrue(url1.startsWith("moz-extension://"), "url1 has correct scheme");
|
||||
browser.test.assertTrue(url1.endsWith("test_file.html"), "url1 has correct leaf name");
|
||||
|
||||
browser.test.assertEq(url1, url2, "url2 matches");
|
||||
browser.test.assertEq(url1, url3, "url3 matches");
|
||||
browser.test.assertEq(url1, url4, "url4 matches");
|
||||
|
||||
browser.test.notifyPass("geturl");
|
||||
});
|
||||
}
|
||||
|
||||
function contentScript() {
|
||||
var url1 = browser.runtime.getURL("test_file.html");
|
||||
var url2 = browser.extension.getURL("test_file.html");
|
||||
browser.runtime.sendMessage([url1, url2]);
|
||||
}
|
||||
|
||||
let extensionData = {
|
||||
background: "(" + backgroundScript.toString() + ")()",
|
||||
manifest: {
|
||||
"content_scripts": [{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"js": ["content_script.js"],
|
||||
"run_at": "document_start"
|
||||
}]
|
||||
},
|
||||
|
||||
files: {
|
||||
"content_script.js": "(" + contentScript.toString() + ")()",
|
||||
},
|
||||
};
|
||||
|
||||
add_task(function* test_contentscript() {
|
||||
let extension = ExtensionTestUtils.loadExtension(extensionData);
|
||||
yield extension.startup();
|
||||
info("extension loaded");
|
||||
|
||||
yield new Promise(resolve => { setTimeout(resolve, 0); });
|
||||
|
||||
let win = window.open();
|
||||
|
||||
win.location = "file_contentscript_page1.html";
|
||||
|
||||
yield Promise.all([waitForLoad(win), extension.awaitFinish("geturl")]);
|
||||
|
||||
win.close();
|
||||
|
||||
yield extension.unload();
|
||||
info("extension unloaded");
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user