Firefox中的Facebook JS API初始化错误:"无法解析无效的源chrome-extension"

时间:2014-03-14 19:44:48

标签: facebook firefox facebook-javascript-sdk

我有一个使用Facebook JS API的简单页面,导致Firefox 27.0.1中出现错误。我已经将它剥离到初始化代码,我仍然得到错误。我没有在IE中得到错误。 (我用1代替了真实的应用ID。)

知道是什么导致了这个吗?为什么Firefox中存在“chrome-extension”错误?

Screenshot of errors

<http>
<head>
</head>
<body>
<div id='fb-root'></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : '1111111111111111',
status : true,
xfbml : true
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
</body>
</http>

1 个答案:

答案 0 :(得分:3)

我现在正在自己的网站上看到这个。这不是它第一次出现。

我的代码(使用jQuery):

$(document).ready(function() {
console.log('page ready');
$.ajaxSetup({ cache: true });
$.getScript('//connect.facebook.net/en_UK/all.js', function(){
    console.log('fb.init calling', FB);
    FB.init({
        appId: '<?=FB_APP_ID?>',
        status: true,
        xfbml: true
    });
    console.log('fb.init called', '<?=FB_APP_ID?>', FB);
    $('#loginbutton,#feedbutton').removeAttr('disabled');
    console.log('activate buttons');
    FB.getLoginStatus(updateStatusCallback, true);
    console.log('getloginstatus called');
});

和我的输出

page ready
<my script> (line 280)
fb.init calling Object { __globalCallbacks={...}, Canvas={...}, CanvasInsights={...}, more...}
<my script> (line 283)
fb.init called <my FB ID omitted> Object { __globalCallbacks={...}, Canvas={...}, CanvasInsights={...}, more...}
<my script> (line 289)
activate buttons
<my script> (line 291)
getloginstatus called
<my script> (line 293)
Content Security Policy: Couldn't parse invalid source chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl
...conds();wa=na.getUTCMilliseconds();}na=(pa<=0||pa>=10000?(pa<0?"-":"+")+o(6,pa<0...
all.js (line 28)
Content Security Policy: Failed to parse unrecognized source chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl
Content Security Policy: Couldn't parse invalid source chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl
Content Security Policy: Failed to parse unrecognized source chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl
Content Security Policy: Couldn't parse invalid source chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl
Content Security Policy: Failed to parse unrecognized source chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl
Content Security Policy: Couldn't parse invalid source chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl
Content Security Policy: Failed to parse unrecognized source chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl

跟踪执行路径,我们看到all.js脚本是异步下载的,并且完成后会调用后面的代码。一切顺利,直到在回调中调用函数FB.getLoginStatus()。此功能在从Facebook下载的all.js脚本中定义。因此,此时发生的任何问题都存在于该文件中,而且我或其他任何人都可以控制Facebook。

正如我所说的那样,我在此问题之前和之后都经历了数小时和数天的痛苦,你所能做的就是等待Facebook修复它。通常一天左右。

您可以在此处Facebook API Status查看有关API状态的详细信息,并Facebook Bug Reporting报告问题。

抱歉,我无法提供更多帮助。