Chrome 66发布后,我们测试Chrome扩展程序的规范失败,因为我们无法以编程方式访问popup.html,因为chrome-extension://<extension-id>/src/popup.html
的请求被阻止了。
我们尝试使用chrome.runtime.id
和chrome.runtime.getURL()
以编程方式获取扩展程序ID。
我们还尝试生成自己的PEM以对扩展进行签名,并使用清单中生成的ID作为扩展密钥。这两种尝试都没有结果。
还有办法以编程方式访问Chrome扩展程序以进行测试吗?
更新:这是我的manifest.json
:
{
"manifest_version": 2,
"name": "Paparazzi",
"version": "1.0.9",
"background": {
"matches": ["<all_urls>"],
"scripts": [
"src/background.js",
"vendor/jszip.js",
"vendor/FileSaver.js",
"vendor/mixpanel.js"
]
},
"browser_action": {
"default_icon": {
"16": "ic-paparazzi-16.png",
"48": "ic-paparazzi-48.png",
"96": "ic-paparazzi-96.png",
"128": "ic-paparazzi-128.png",
"256": "ic-paparazzi-256.png"
},
"default_popup": "src/popup.html"
},
"commands": {
"capture_screen": {
"suggested_key": {
"default": "Ctrl+Shift+E",
"mac": "Command+Shift+E"
},
"description": "Capture screenshot of current tab"
}
},
"content_security_policy":
"script-src 'self' https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js; object-src 'self'",
"icons": {
"16": "ic-paparazzi-16.png",
"48": "ic-paparazzi-48.png",
"96": "ic-paparazzi-96.png",
"128": "ic-paparazzi-128.png",
"256": "ic-paparazzi-256.png"
},
"permissions": [
"activeTab",
"cookies",
"identity",
"identity.email",
"notifications",
"tabCapture",
"tabs",
"webRequest",
"webRequestBlocking",
"http://*/",
"*://*.sharethrough.com/*",
"*://localhost/*",
"<all_urls>"
],
"web_accessible_resources": [
"src/*",
"vendor/fonts/MetricWeb-Regular.woff",
"vendor/bootstrap.min.css"
],
"key": "bgcanlbkmndllogdnbohopfomoknmjmf"
}
答案 0 :(得分:0)
我在Chrome 66.0.3359.117上,我能够获得这样的文件;
chrome.runtime.getURL("popups/popup.html");
window.open()
成功让它打开页面。在"web_accessible_resources"
下未指定文件夹或文件时,它不起作用。
"web_accessible_resources": [
"popups/*"
]
如果问题不在清单上,那么它可能与测试软件有关,而与Chrome无关。