0

每次 Chrome 请求代理用户/密码时,我都会编写一个扩展来发送代理身份验证,但是每次打开请求 http 基本身份验证的网页时都会出现问题,它会在“等待 XXXX”处停止,XXXX 是我的扩展名.

我的代码如下:

var gPendingCallbacks = [];
var bkg = chrome.extension.getBackgroundPage();

chrome.webRequest.onAuthRequired.addListener(handleAuthRequest,
  {urls: ["<all_urls>"]}, ["asyncBlocking"]);

function processPendingCallbacks() {
  var callback = gPendingCallbacks.pop();
  callback({authCredentials: {username: 'user',
                              password: 'pass'}});
}

function handleAuthRequest(details, callback) {
  gPendingCallbacks.push(callback);
  if (details.isProxy === true ){
  processPendingCallbacks();
    }
}

我该如何解决这个问题?

4

1 回答 1

1

改变:

function handleAuthRequest(details, callback) {
    gPendingCallbacks.push(callback);
    if (details.isProxy === true ){
        processPendingCallbacks();
    }
}

至:

function handleAuthRequest(details, callback) {
    gPendingCallbacks.push(callback);
    processPendingCallbacks();
}
于 2012-09-29T14:27:46.133 回答