--- title: Consola Web slug: Tools/Web_Console tags: - Debugging - Guide - NeedsTranslation - Security - Tools - TopicStub - Web Development - 'Web Development:Tools' - web console translation_of: Tools/Web_Console ---
La Consola Web:
It's part of the replacement for the old Error Console built into Firefox: but the Error Console showed errors, warnings, and messages from all web pages, from the browser's own code, and from add-ons. This makes it much more difficult to see which messages are relevant to a specific page. The Web Console is always associated with a specific web page and only shows information associated with that page.
The other half of the replacement for the Error console is the Browser Console, which shows errors, warnings, and messages from the browser's code and from add-ons.
{{EmbedYouTube("C6Cyrpkb25k")}}
To open the Web Console select "Web Console" from the Web Developer submenu in the Firefox Menu (or Tools menu if you display the menu bar or are on Mac OS X), or by pressing its Control-Shift-K (Command-Option-K on the Mac) keyboard shortcut.
The Toolbox will appear at the bottom of the browser window, with the Web Console activated (it's just called "Console" in the DevTools toolbar):
Underneath the DevTools Window's own toolbar, the Web Console's interface is split into three sections:
Most of the Web Console is occupied by the message display pane:
The message display pane displays the following sorts of messages:
Each message is displayed as a single row in the pane.
HTTP requests are logged with a line that looks like this:
By default, the Web Console does not log request and response bodies: to do this, activate the context menu in the Web Console and select "Log Request and Response Bodies".
If you click on the message, you'll see a window like this, containing more details about the request and response:
Scrolling down reveals the response headers. By default, the Web Console does not log request and response bodies: to do this, activate the context menu in the Web Console and select "Log Request and Response Bodies", reload the page, and you'll then see them in the "Inspect Network Request" window.
Only the first megabyte of data is logged for each request or response body, so very large requests and responses will be truncated.
Warnings and errors are logged with a line looking something like this:
The security messages shown in the Web Console help developers find potential or actual vulnerabilities in their sites. Additionally, many of these messages help educate developers because they end with a “Learn More” link that takes you to a page with background information and advice for mitigating the issue.
The complete list of security messages is as follows:
Message | Details |
---|---|
Blocked loading mixed active content | The page contained mixed active content: that is, the main page was served over HTTPS, but asked the browser to load "active content", such as scripts, over HTTP. The browser blocked this active content. See Mixed Content for more details. |
Blocked loading mixed display content | The page contained mixed display content: that is, the main page was served over HTTPS, but asked the browser to load "display content", such as images, over HTTP. The browser blocked this display content. See Mixed Content for more details. |
Loading mixed (insecure) active content on a secure page
Introduced in Firefox 26 |
The page contained mixed active content: that is, the main page was served over HTTPS, but asked the browser to load "active content", such as scripts, over HTTP. The browser loaded this active content. See Mixed Content for more details. |
Loading mixed (insecure) display content on a secure page
Introduced in Firefox 26 |
The page contained mixed display content: that is, the main page was served over HTTPS, but asked the browser to load "display content", such as images, over HTTP. The browser loaded this display content. See Mixed Content for more details. |
This site specified both an X-Content-Security-Policy/Report-Only header and a Content-Security-Policy/Report-Only header. The X-Content-Security-Policy/Report-Only header(s) will be ignored. | See Content Security Policy for more details. |
The X-Content-Security-Policy and X-Content-Security-Report-Only headers will be deprecated in the future. Please use the Content-Security-Policy and Content-Security-Report-Only headers with CSP spec compliant syntax instead. | See Content Security Policy for more details. |
Password fields present on an insecure (http://) page. This is a security risk that allows user login credentials to be stolen.
Introduced in Firefox 26 |
Pages containing login forms must be served over HTTPS, not HTTP. |
Password fields present in a form with an insecure (http://) form action. This is a security risk that allows user login credentials to be stolen.
Introduced in Firefox 26 |
Forms containing password fields must submit them over HTTPS, not HTTP. |
Password fields present on an insecure (http://) iframe. This is a security risk that allows user login credentials to be stolen.
Introduced in Firefox 26 |
iframes containing login forms must be served over HTTPS, not HTTP. |
The site specified an invalid Strict-Transport-Security header. | See HTTP Strict Transport Security for more details. |
Bug 863874 is the meta-bug for logging relevant security messages to the Web Console. If you have more ideas for useful features like the ones discussed here, or are interested in contributing, check out the metabug and its dependencies.
Reflow events are only logged from Firefox Desktop 27+ and Firefox OS 1.3+.
The Web Console also logs reflow events. A reflow is the name given to the operation in which the browser calculates the layout of all or part of the page. Reflows occur when a change has happened to a page that the browser thinks affects the layout. Many events can trigger reflows, including: resizing the browser window, activating pseudoclasses like :hover, or manipulating the DOM in JavaScript.
Because reflows can be computationally expensive and directly affect the user interface, they can have a big impact on the responsiveness of a website or web app. By logging reflow events the Web Console can give you insight into when reflow events are being triggered, how long they take to execute and, if the reflows are synchronous reflows triggered from JavaScript, which code triggered them.
Reflow events are logged under the CSS category, as "Log" messages, as distinct from CSS errors or warnings. By default, they are disabled. You can enable them by clicking the "CSS" button in the toolbar and selecting "Log".
Each message is labeled "reflow" and shows the time taken to execute the reflow:
If the reflow is a synchronous reflow triggered from JavaScript, it also shows a link to the line of code that triggered the reflow:
Click the link to open the file in the Debugger.
If a change is made that invalidates the current layout - for example, the browser window is resized or some JavaScript modifies an element's CSS - the layout is not recalculated immediately. Instead, the reflow happens asynchronously, the next time the browser decides it needs to be done (generally, the next time the browser repaints). In this way the browser can save up a collection of invalidating changes and recalculate their effect at once.
However, if some JavaScript code reads a style that has been modified, then the browser must perform a synchronous reflow in order to calculate the computed style to return. For example, code like this will cause an immediate, synchronous, reflow, when it calls window.getComputedStyle(thing).height
:
var thing = document.getElementById("the-thing"); thing.style.display = "inline-block"; var thingHeight = window.getComputedStyle(thing).height;
Because of this, it's a good idea to avoid interleaving write and read calls to an element's styles when manipulating the DOM, because every time you read back a style that has been invalidated by a previous write call, you force a synchronous reflow.
Commands sent to the browser using the Web Console's command line, and the corresponding responses, are logged using lines like this:
The dark gray bar indicates that these are input/output messages, while the direction of the arrow discriminates between input and output.
You can use the toolbar along the top to constrain the results displayed.
You can display only specific types of messages or only message containing specific strings.
Finally, you can use this toolbar to clear the log.
You can interpret JavaScript expressions in real time using the command line provided by the Web Console.
To enter expressions just type into the command line and press "Enter". To enter multiline expressions, use "Shift+Enter" instead of "Enter".
The expression you type is echoed in the message display window, followed by the result:
You can access variables defined in the page, both built-in variables like window
and variables added by JavaScript like jQuery
:
The command line has autocomplete: enter the first few letters and a popup appears with possible completions:
Type "Enter" or "Tab" to accept the suggestion, use the up/down arrows to move to a different suggestion, or just keep typing if you don't like any of the suggestions.
New in Firefox 28
Starting from Firefox 28, the console suggests completions from the scope of the currently executing stack frame. This means that if you've hit a breakpoint in a function you get autocomplete for objects local to the function.
If the result object is an object it appears in square brackets and is underlined, like this: [object Function]
. Click on it, and you'll see a new panel appear containing details of the object:
To dismiss this panel press "Escape".
You can define your own variables, and then access them:
The command line remembers commands you've typed: to move back and forward through your history, use the up and down arrows.
Shortcut | Description |
↑ | Moves to the previous entry in the command history, or, if an autocomplete popup is open, highlights the previous suggestion. |
↓ | Moves to the next entry in the command history, or, if an autocomplete popup is open, highlights the next suggestion. |
Ctrl-A | Moves the cursor to the beginning of the line. (Note: beginning with Firefox 22, this will select all text on Windows) |
Ctrl-E | Moves the cursor to the end of the line. |
Return | Executes the code typed on the command line, or, if an autocomplete popup is open, chooses the current suggestion. |
Shift-Return | Expands the height of the text input box for the command line by a line. |
Escape | Cancels the autocompletion popup. |
Tab | Generates an autocomplete suggestion and accepts the first one. |
{{ page("/en/Using_the_Web_Console/Helpers", "The commands") }}
The split console is new in Firefox 28.
{{EmbedYouTube("G2hyxhPHyXo")}}
Starting in Firefox 28, you can use the console alongside other tools. While you're in another tool in the Toolbox, just press "Escape" or press the "Toggle split console" button in the Toolbar. The toolbox will now appear split, with the original tool above and the web console underneath.
As usual, $0
works as a shorthand for the element currently selected in the Inspector:
When you use the split console with the debugger, the console's scope is the currently executing stack frame. So if you hit a breakpoint in a function, the scope will be the function's scope. You'll get autocomplete for objects defined in the function, and can easily modify them on the fly:
{{ languages( { "ja": "ja/Tools/Web_Console"} ) }}