SignalR'许可被拒绝'在Firefox SDK Addon中

时间:2016-07-09 07:03:10

标签: javascript signalr firefox-addon-sdk

背景信息:我尝试制作Firefox SDK插件,以便在新消息到达TFS会议室聊天时显示吐司通知。 我正在移植适用于Google Chrome的existing code

代码提取:

index.js

[Files]
Source: "InnoCallback.dll"; DestDir: "{tmp}"; Flags: dontcopy

[Code]

var
  MinimizerCheckBox: TCheckBox;

...

type
  TTimerProc = procedure(h: LongWord; msg: LongWord; idevent: LongWord; dwTime: LongWord);

function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord;
   external 'wrapcallback@files:innocallback.dll stdcall';
function SetTimer(hWnd: longword; nIDEvent, uElapse: longword; lpTimerFunc: longword): longword;
  external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd: HWND; uIDEvent: UINT): BOOL; 
  external 'KillTimer@user32.dll stdcall'; 

var
  CheckTimerID: Integer;

procedure StopCheckTimer;
begin
  Log('Killing timer');
  KillTimer(0, CheckTimerID);
  CheckTimerID := 0;
end;

procedure CheckProc(h: LongWord; msg: LongWord; idevent: LongWord; dwTime: LongWord);
begin
  Log('Timer elapsed');
  StopCheckTimer;
  MinimizerCheckBox.Checked := True;
end;

procedure CurPageChanged(CurPageID: Integer);
var
  CheckTimerCallback: LongWord;
begin
  if CurPageID = wpXXX then // your page id
  begin
    Log('Starting 5s timer');
    CheckTimerCallback := WrapTimerProc(@CheckProc, 4);
    CheckTimerID := SetTimer(0, 0, 5000, CheckTimerCallback);
  end
    else
  if CheckTimerID <> 0 then
  begin
    StopCheckTimer;
  end;
end;

数据/ notifications.js

var pageMod = require("sdk/page-mod");
pageMod.PageMod({
    include: "*.tfsservername",
    contentScriptFile: [self.data.url("jquery.min.js"), self.data.url("notifications.js")]
});

问题: $(function() { // [...] checking notifications permissions here // Suscribing to new messages unsafeWindow.$.connection.chatHub.on('messageReceived', function() {/*showing notification here*/}); }); 会在文件$.connection.chatHub.on(...)中引发错误 Permission denied to access property Symbol.toPrimitive

使用javascript控制台执行的同一行代码(没有tfs/_static/3rdParty/_scripts/jquery.signalR-2.2.0.min.js)实际上可以正常工作所以我猜测这可能是因为插件代码是从与...分开执行的页面代码,但不知道如何解决这个问题,或者问题的实际来源。

0 个答案:

没有答案