Firefox console ReferenceError: browser is not defined - firefox

I am trying to learn WebExtension development for Firefox. I find the window debugging tools EXTREMELY useful as I can interactively evaluate javascript code in the window context.
For the Webextension APIs at the browser level, I have been totally unsuccessful when trying to similarly use the browser console. For example trying to use the tabs API
Click on menu->developer->browser console
In the console command line enter any expression beginning with browser and I get
"ReferenceError: browser not defined"
I have tried in chrome and got same error (read article about chrome.* vs browser.*)
For example trying to find all tabs:
var querying=browser.tabs.query(queryInfo)
or
chrome.tabs.query()
Returns browser or chrome as not defined
Please help

As described at [1] WebExtension APIs are present in pages contained inside a WebExtension. The browser console gives you access to the javascript environment used to implement the main browser user interface which is a very different environment.
To experiment with the WebExtensions APIs interactively, your best bet is probably to create a very simple WebExtension with an empty background page, then attach to it with the debugger [2]
[1] https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API
[2] https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Debugging

Related

Can't debug my microsoft teams tab using DevTools

I'm trying to get console logs from my tab using DevTools in Microsoft Teams. I can open the console, but my logs are not showed and I'm getting the following error instead:
The Content-Security-Policy directive 'prefetch-src' is implemented behind a flag which is currently disabled.
I tested my application in Chrome and I can see the logs properly.
If you mean in the desktop version of Teams, then when you access via DevTools (sounds like this is what you're doing), try choosing All WebContents. Remember, Teams is an electron app historically, so everything is a "web" content - you'll get multiple DevTools windows and you need to find which is the right one for your tab. Screenshot below shows this option.
But, a better tip, if you're actively developing your tab, is just to run Teams in a browser directly (browse to teams.microsoft.com) - then it's just a single DevTools option and easier to manage.

Firefox developer tools: restrict messages to current site

Is there any way of filtering out non-website warnings and errors?
I’m trying to use the console to troubleshot my JavaScript code, but the console is cluttered with messages from other sources such as Firefox addons. I some cases I can’t find my own console.log messages because of these messages.
Is there some sort of flag or setting to limit messages to the current site?
Only the Browser Console (available e.g. via Ctrl+Shift+J / Command+Shift+J or Firefox Menu > More Tools > Browser Console) shows messages coming from all different sources including add-ons.
The normal Web Console within the Firefox DevTools (available e.g. via Ctrl+Shift+K / Command+Option+K or F12 > Console) only contains messages from the current website.
So, you should ensure you're looking at the right console. If you're sure you are using the right console, then it's a bug and you should report it to Mozilla.

Is it possible to put Firefox into full screen mode programmatically?

I'm testing something using Splinter / Selenium, using the Firefox webdriver.
I'd like to automate getting the browser into full screen mode. I've tried mozRequestFullScreen but it won't co-operate - I get errors about it not being triggered by a user event (presumably this is a security thing). Is there a way to run Firefox where it will allow this? Or a profile setting or something?

Full privileged console for firefox

I'd like to play around with developing firefox addons, and I'm going to be accessing stuff like Components.utils and other objects, which are not accessible from the client code.
I've tried native web console and firebug console, and both give me an error when I'm trying to access utils object.
Is there firefox javascript console, which would give me full access to all firefox objects?
Use devtools:Scratchpad (shift F4; it's built into Firefox and is accessible under the web development menu). You'll need to set the pref devtools.chrome.enabled to true in about:config, and set scratchpad environment to browser from Scratchpad's menu. Once you've done that, whatever code you run in scratchpad can access chrome objects and operates with chrome privileges.
No addons or separate applications are necessary.
Try MozRepl.
I'm using it with rlwrap telnet localhost ....

How to find the source of IE8 Internet explorer has modified this page to help prevent cross-site scripting

One of my customers gets "Internet explorer has modified this page to help prevent cross-site scripting" error on her website on IE8.
The page has several ajax calls to the same domain + calls to standard js files outside the domain such as google analytics.
How can I detect which call from the browser is actually causing it?
You can see your request and other error information with the help of IE Developer Toolbar. See its documentation for more info about it. It is addon of IE, once you install it, it will be integrated into IE.

Resources