gpt4 book ai didi

javascript - 需要 ("sdk/window/utils").windows() 的私有(private)窗口

转载 作者:行者123 更新时间:2023-11-28 01:13:55 24 4
gpt4 key购买 nike

我在package.json中使用:"permissions": {"private-browsing": true}

根据描述,函数windows()返回私有(private)窗口就足够了: https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/window_utils#Private_windows

但是,它们仍然被忽略。

如何require("sdk/window/utils").windows();返回私有(private)窗口?

最佳答案

不确定这是否是一个文档错误(在实际文档和实现中的代码注释中),但实现实际上并不关心权限,只关心 undocumented option :

/**
* Returns an array of all currently opened windows.
* Note that these windows may still be loading.
*/
function windows(type, options) {
options = options || {};
let list = [];
let winEnum = WM.getEnumerator(type);
while (winEnum.hasMoreElements()) {
let window = winEnum.getNext().QueryInterface(Ci.nsIDOMWindow);
// Only add non-private windows when pb permission isn't set,
// unless an option forces the addition of them.
if (!window.closed && (options.includePrivate || !isWindowPrivate(window))) {
list.push(window);
}
}
return list;
}
exports.windows = windows;

所以事实证明您需要像这样调用该函数:

require("sdk/window/utils").windows(null, {includePrivate: true});

如果您输入 filed a bug 那就太好了。

关于javascript - 需要 ("sdk/window/utils").windows() 的私有(private)窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24082423/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com