Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

Learn More

Funcions `loadOneTab` and `loadURI` in 2023 in Firefox Experimental API?

  • 2 个回答
  • 0 人有此问题
  • 3 次查看
  • 最后回复者为 look997

more options

I am using the Experimental API in my private Firefox extension.

So far, I've been using Firefox 102 ESR, but I'm planning to switch to Firefox ESR 115. There's already a Firefox 115 Beta available, so I've started testing it with my private extension.

So far, I've been using internal Firefox functions like `loadOneTab` and `loadURI` and it worked very well.

I used the `loadOneTab` function like this:

``` const placesURL = "chrome://browser/content/places/places.xhtml"; window.gBrowser.loadOneTab( placesURL, { inBackground: false, allowThirdPartyFixup : true, relatedToCurrent : true, triggeringPrincipal : services.scriptSecurityManager.getSystemPrincipal() } ); ```

But the `loadOneTab` function no longer exists at all in Firefox's internal API. What should I replace it with?

I found the function `_createTab`:

``` // window.gBrowser._createTab({ uriString: placesURL }); ```

But the `_createTab` function returns an error:

``` Uncaught Error: UserInteraction with id "browser.tabs.opening" was not initialized ```

...I guess this is by security to make this function called only by user action? And I call this function inside `async function`.

Is it somehow possible to open a new tab from the Experimental API in Firefox 115 beta? I need this very badly. Really very much.

---

I used the `loadURI` function like this:

``` window.gBrowser.selectedBrowser.loadURI(linkGo, {triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal()}); ```

The `loadURI` function appears to still be available in Firefox's internal API, but returns an error like this:

``` TypeError: 'uri' member of CancelContentJSOptions is not an object. RemoteWebNavigation.sys.mjs:28:41 ```

How to overcome this error?

I am using the Experimental API in my private Firefox extension. So far, I've been using Firefox 102 ESR, but I'm planning to switch to Firefox ESR 115. There's already a Firefox 115 Beta available, so I've started testing it with my private extension. So far, I've been using internal Firefox functions like `loadOneTab` and `loadURI` and it worked very well. I used the `loadOneTab` function like this: ``` const placesURL = "chrome://browser/content/places/places.xhtml"; window.gBrowser.loadOneTab( placesURL, { inBackground: false, allowThirdPartyFixup : true, relatedToCurrent : true, triggeringPrincipal : services.scriptSecurityManager.getSystemPrincipal() } ); ``` But the `loadOneTab` function no longer exists at all in Firefox's internal API. What should I replace it with? I found the function `_createTab`: ``` // window.gBrowser._createTab({ uriString: placesURL }); ``` But the `_createTab` function returns an error: ``` Uncaught Error: UserInteraction with id "browser.tabs.opening" was not initialized ``` ...I guess this is by security to make this function called only by user action? And I call this function inside `async function`. Is it somehow possible to open a new tab from the Experimental API in Firefox 115 beta? I need this very badly. Really very much. --- I used the `loadURI` function like this: ``` window.gBrowser.selectedBrowser.loadURI(linkGo, {triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal()}); ``` The `loadURI` function appears to still be available in Firefox's internal API, but returns an error like this: ``` TypeError: 'uri' member of CancelContentJSOptions is not an object. RemoteWebNavigation.sys.mjs:28:41 ``` How to overcome this error?

所有回复 (2)

more options

Hi

I recommend that you ask about this on the dedicated add-ons forum at:

https://discourse.mozilla.org/c/add-ons/35

more options

选择的解决方案