且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么我的Google Chrome扩展程序只能打开25个选项卡?

更新时间:2023-12-05 19:21:58

=http://code.google.com/codesearch#OAMlx_jo-ck/src/content/renderer/render_view_impl.cc&exact_package=chromium&q=kMaximumNumberOfUnacknowledgedPopups&type=cs&l=290 =nofollow>在 window.open 调用上有意设置上限。请参阅Chromium错误 2632 3382 作为背景,但简而言之,这个想法是为了防止拒绝服务(UI -

扩展API如 chrome.tabs.create (正如PAEz的答案所建议的)不受这些API的约束,因为扩展已经有特权访问。


I have a piece of code here that just doesn't want to work right as a Chrome Extension.

As far as I can tell, everything works perfectly, except it stops opening pages around tab 25, no matter how many tabs should be opened. I checked the code and it attempts to open every single link properly, but in reality it doesn't. Any ideas?

for (x = 0; x<55; x++){
   window.open();
}

There is an intentional upper bound of 25 on window.open calls. See Chromium bugs 2632 and 3382 for background, but in brief, the idea is to prevent denial-of-service (both UI-wise and memory-wise) attacks from pages that open popups indefinitely.

Extension APIs like chrome.tabs.create (as PAEz's answer suggests) are not subject to these APIs, since extensions are privileged access already.