我很难过。我的Chrome扩展程序主要基于popup.html。
它在Chrome 65.x上运行良好。我收到了Chrome 66.0上用户的错误报告,说该扩展程序无法正确显示。
我将Chrome更新为66.0,我可以重现该错误。 popup.html快速闪烁并被裁剪成一个小小的白色方块,好像它是空的。
可能是什么问题?
清单:
{
"description": "...",
"manifest_version": 2,
"name": "...",
"version": "1.5.0",
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"permissions": [
"tabs",
"cookies",
"<all_urls>"
],
"browser_action": {
"browser_style": true,
"default_popup": "popup/popup.html"
}
}
popup.html包含KnockoutJS的本地副本。删除所有Javascript时,它正确加载。但是,自从Chrome 65正常工作以来,JS代码没有任何变化。
答案 0 :(得分:0)
Chrome 66问题:https://bugs.chromium.org/p/chromium/issues/detail?id=428044
临时解决方法是在加载后重新设置正文样式以使用setTimeout强制重绘。
// This height calculation is excessive due to padding, but it's not worth
// the extra coding effort to get it pixel-perfect (e.g. getComputedStyle).
const height = document.body.clientHeight;
// Set it slightly bigger immediately so hopefully this will lead to less
// flashing/refreshing. It's not clear whether this always worksaround the
// bug though :(.
document.body.style.height = `${height + 1}px`;
// Schedule an update in case the window is still too small. Hopefully
// this will catch the rest. If we already workedaround it, we'll only
// make the window slightly bigger so the user won't notice.
setTimeout(() => document.body.style.height = `${height + 2}px`, 100);
setTimeout(() => document.body.style.height = ``, 110)