Google Chrome / Firefox do not see extension output in console












7















I am trying to test sample code for web extension for browsers.
But, it doesn't work. I checked the console for Google Chrome and also for Firefox. It doesn't print anything. The following is my code:



manifest.json:



{
"description": "Demonstrating webRequests",
"manifest_version": 2,
"name": "webRequest-demo",
"version": "1.0",

"permissions": [
"webRequest"
],
"background": {
"scripts": ["background.js"]
}
}


background.js:



function logURL(requestDetails) {
console.log("Loading: " + requestDetails.url);
}

chrome.webRequest.onBeforeRequest.addListener(
logURL,
{urls: ["<all_urls>"]}
);
console.log("Hell o extension background script executed");


Am I missing something?










share|improve this question

























  • Possible duplicate of How to use console.log() to debug a Chrome extension?

    – Haibara Ai
    Aug 15 '16 at 0:07











  • Technically, a duplicate of Where to read console messages from background.js in a Chrome extension? Practically, has some independent worth as it asked for Firefox-specific info and has a corresponding answer. So, not swinging the dupehammer.

    – Xan
    Nov 15 '16 at 10:44


















7















I am trying to test sample code for web extension for browsers.
But, it doesn't work. I checked the console for Google Chrome and also for Firefox. It doesn't print anything. The following is my code:



manifest.json:



{
"description": "Demonstrating webRequests",
"manifest_version": 2,
"name": "webRequest-demo",
"version": "1.0",

"permissions": [
"webRequest"
],
"background": {
"scripts": ["background.js"]
}
}


background.js:



function logURL(requestDetails) {
console.log("Loading: " + requestDetails.url);
}

chrome.webRequest.onBeforeRequest.addListener(
logURL,
{urls: ["<all_urls>"]}
);
console.log("Hell o extension background script executed");


Am I missing something?










share|improve this question

























  • Possible duplicate of How to use console.log() to debug a Chrome extension?

    – Haibara Ai
    Aug 15 '16 at 0:07











  • Technically, a duplicate of Where to read console messages from background.js in a Chrome extension? Practically, has some independent worth as it asked for Firefox-specific info and has a corresponding answer. So, not swinging the dupehammer.

    – Xan
    Nov 15 '16 at 10:44
















7












7








7


6






I am trying to test sample code for web extension for browsers.
But, it doesn't work. I checked the console for Google Chrome and also for Firefox. It doesn't print anything. The following is my code:



manifest.json:



{
"description": "Demonstrating webRequests",
"manifest_version": 2,
"name": "webRequest-demo",
"version": "1.0",

"permissions": [
"webRequest"
],
"background": {
"scripts": ["background.js"]
}
}


background.js:



function logURL(requestDetails) {
console.log("Loading: " + requestDetails.url);
}

chrome.webRequest.onBeforeRequest.addListener(
logURL,
{urls: ["<all_urls>"]}
);
console.log("Hell o extension background script executed");


Am I missing something?










share|improve this question
















I am trying to test sample code for web extension for browsers.
But, it doesn't work. I checked the console for Google Chrome and also for Firefox. It doesn't print anything. The following is my code:



manifest.json:



{
"description": "Demonstrating webRequests",
"manifest_version": 2,
"name": "webRequest-demo",
"version": "1.0",

"permissions": [
"webRequest"
],
"background": {
"scripts": ["background.js"]
}
}


background.js:



function logURL(requestDetails) {
console.log("Loading: " + requestDetails.url);
}

chrome.webRequest.onBeforeRequest.addListener(
logURL,
{urls: ["<all_urls>"]}
);
console.log("Hell o extension background script executed");


Am I missing something?







google-chrome-extension firefox-addon google-chrome-devtools firefox-developer-tools firefox-webextensions






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 1 '17 at 1:38









Makyen

20.6k83971




20.6k83971










asked Aug 12 '16 at 8:50









harishharish

1331215




1331215













  • Possible duplicate of How to use console.log() to debug a Chrome extension?

    – Haibara Ai
    Aug 15 '16 at 0:07











  • Technically, a duplicate of Where to read console messages from background.js in a Chrome extension? Practically, has some independent worth as it asked for Firefox-specific info and has a corresponding answer. So, not swinging the dupehammer.

    – Xan
    Nov 15 '16 at 10:44





















  • Possible duplicate of How to use console.log() to debug a Chrome extension?

    – Haibara Ai
    Aug 15 '16 at 0:07











  • Technically, a duplicate of Where to read console messages from background.js in a Chrome extension? Practically, has some independent worth as it asked for Firefox-specific info and has a corresponding answer. So, not swinging the dupehammer.

    – Xan
    Nov 15 '16 at 10:44



















Possible duplicate of How to use console.log() to debug a Chrome extension?

– Haibara Ai
Aug 15 '16 at 0:07





Possible duplicate of How to use console.log() to debug a Chrome extension?

– Haibara Ai
Aug 15 '16 at 0:07













Technically, a duplicate of Where to read console messages from background.js in a Chrome extension? Practically, has some independent worth as it asked for Firefox-specific info and has a corresponding answer. So, not swinging the dupehammer.

– Xan
Nov 15 '16 at 10:44







Technically, a duplicate of Where to read console messages from background.js in a Chrome extension? Practically, has some independent worth as it asked for Firefox-specific info and has a corresponding answer. So, not swinging the dupehammer.

– Xan
Nov 15 '16 at 10:44














3 Answers
3






active

oldest

votes


















17














Firefox



In Firefox, your code works (outputs to console), as it is written in the question.



If you are not seeing it in the console, then you are, probably, looking at the wrong console.



Mozilla describes what extension output can be seen in which console in their Debugging page.



Browser Console



You should be using the Browser Console. You can access it from Tools➜Web Developer➜Browser Console (keyboard shortcut Ctrl-Shift-J, or Cmd-Shift-J on Mac).



Browser Toolbox



If you have it enabled, you could also use the Browser Toolbox console. You can access it from Tools➜Web Developer➜Browser Toolbox (keyboard shortcut Ctrl-Alt-Shift-I; On a Mac: Cmd-Alt-Shift-I).



Add-on Debugger



To debug your add-on you can use the Add-on Debugger. You can access it though about:debugging➞Debug.



Web Console



You, probably, are looking at the Web Console (keyboard shortcut F12) which is associated with only a single tab. This is what you want when debugging a webpage, but not an add-on. For a content script which is injected in that tab, the console.log() output will show up in this console. However, you will not see output from any other portion of your add-on (e.g. not content scripts in other tabs, not background scripts, etc.).



Google Chrome



Showing the correct console for your extension is a bit more complex in Chrome. Console output will show up in only one of multiple possible places, depending on from what context the console.log() was executed. Each of the following DevTools are independent of each other and are displayed in separate windows, or tabs. Displaying in the associated tab (bottom or side) is the default for the DevTools associated with web pages and content scripts, because those are specific to the tab. For the web page/content script DevTools, you have the option of having it displayed in its own separate window, or docked inside the tab (side or bottom).



For your Background page



As Srujan Reddy explained, you have to go through multiple selections on a drop-down menu, to get to the chrome://extensions page (or you can type that in by hand as the URL, or use a bookmark) then select both a checkbox ("Developer mode") and then click on the "background page" link. Then, you have to select the "Console" tab on the window that pops up.



It is much easier to show what you have to do:
Show console for extension on Google Chrome



For your Content Scripts



Output will be shown in the regular web console (in the web Developer Tools). You can open it by pressing F12 (or other shortcuts) in the webpage in which your content script was injected. Each web console will only show the output from the scripts injected in that tab.



Doing the above with show the console.* output from your extension, but will result in the console JavaScript command line, debugger, etc. being in the context of the page, not the content script.



If you want to use the console JavaScript command line in the context of the content scripts which are injected into a web page, you need to select your extension's content script context from the drop-down menu in the upper left of the Console window. This drop-down menu will normally start with the value "top". The drop down will have selections for each of the content script contexts (one per extension that has script(s) injected).



For your Popup



Right-click on your browserAction button and select "Inspect Popup". Alternately, right-click within the popup and select "Inspect". Either will open the DevTools for the popup page. The popup will be kept open under more conditions than it normally would, but will still be closed if you switch tabs, etc.



For your Options page



Right-click within the main content of the Options popup (not the title bar) and select "Inspect". This will open the DevTools for the options page.



For your panel or a page from within your extension loaded in a tab



When the panel or tab is focused, you can open the DevTools by pressing F12 (or other shortcuts), or by opening the context menu (right-click) and selecting "Inspect".






share|improve this answer


























  • @Mayken for popups is not working. Those alternatives are not available at least in ffx 55

    – gal007
    Jun 23 '17 at 13:29











  • @gal007, What are you not seeing? In which console? I'm seeing popup console.log() output just fine in Firefox Developer Edition v55b3 in the Browser Console, the Browser Toolbox and the Add-on Debugger. In Firefox Nightly v56, I also see popup console.log() output in all three tools. I did experience problems with the Browser Toolbox and Add-on Debugger when I tried to use them simultaneously in multiple instances of Firefox. However, they were broken completely (in all but the first instance started, when trying to use >1 instance of Firefox using those tools), not just for popup output.

    – Makyen
    Jun 28 '17 at 8:19



















4














Which console are you viewing in for the logs?



If you are viewing console on a tab, then that is the wrong place.



Open settings / Extensions or in a new tab type



chrome://extensions


Under your extension click on "background page" link which is where you can watch for logs



**Make sure Developer mode is checked






share|improve this answer































    1














    Yes for Chrome you have to click the background page link mentioned, but it won't be there unless you set it to be persistent:



    "background": {
    "persistent": true,
    "scripts": ["background.js"]
    }





    share|improve this answer





















    • 1





      This is not, necessarily, accurate. At least with the code exactly as in the question, when loaded using "Load unpackaged extension...", setting "persistent": true is not required to have the "background page" link showing.

      – Makyen
      Aug 13 '16 at 20:32











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f38913799%2fgoogle-chrome-firefox-do-not-see-extension-output-in-console%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    17














    Firefox



    In Firefox, your code works (outputs to console), as it is written in the question.



    If you are not seeing it in the console, then you are, probably, looking at the wrong console.



    Mozilla describes what extension output can be seen in which console in their Debugging page.



    Browser Console



    You should be using the Browser Console. You can access it from Tools➜Web Developer➜Browser Console (keyboard shortcut Ctrl-Shift-J, or Cmd-Shift-J on Mac).



    Browser Toolbox



    If you have it enabled, you could also use the Browser Toolbox console. You can access it from Tools➜Web Developer➜Browser Toolbox (keyboard shortcut Ctrl-Alt-Shift-I; On a Mac: Cmd-Alt-Shift-I).



    Add-on Debugger



    To debug your add-on you can use the Add-on Debugger. You can access it though about:debugging➞Debug.



    Web Console



    You, probably, are looking at the Web Console (keyboard shortcut F12) which is associated with only a single tab. This is what you want when debugging a webpage, but not an add-on. For a content script which is injected in that tab, the console.log() output will show up in this console. However, you will not see output from any other portion of your add-on (e.g. not content scripts in other tabs, not background scripts, etc.).



    Google Chrome



    Showing the correct console for your extension is a bit more complex in Chrome. Console output will show up in only one of multiple possible places, depending on from what context the console.log() was executed. Each of the following DevTools are independent of each other and are displayed in separate windows, or tabs. Displaying in the associated tab (bottom or side) is the default for the DevTools associated with web pages and content scripts, because those are specific to the tab. For the web page/content script DevTools, you have the option of having it displayed in its own separate window, or docked inside the tab (side or bottom).



    For your Background page



    As Srujan Reddy explained, you have to go through multiple selections on a drop-down menu, to get to the chrome://extensions page (or you can type that in by hand as the URL, or use a bookmark) then select both a checkbox ("Developer mode") and then click on the "background page" link. Then, you have to select the "Console" tab on the window that pops up.



    It is much easier to show what you have to do:
    Show console for extension on Google Chrome



    For your Content Scripts



    Output will be shown in the regular web console (in the web Developer Tools). You can open it by pressing F12 (or other shortcuts) in the webpage in which your content script was injected. Each web console will only show the output from the scripts injected in that tab.



    Doing the above with show the console.* output from your extension, but will result in the console JavaScript command line, debugger, etc. being in the context of the page, not the content script.



    If you want to use the console JavaScript command line in the context of the content scripts which are injected into a web page, you need to select your extension's content script context from the drop-down menu in the upper left of the Console window. This drop-down menu will normally start with the value "top". The drop down will have selections for each of the content script contexts (one per extension that has script(s) injected).



    For your Popup



    Right-click on your browserAction button and select "Inspect Popup". Alternately, right-click within the popup and select "Inspect". Either will open the DevTools for the popup page. The popup will be kept open under more conditions than it normally would, but will still be closed if you switch tabs, etc.



    For your Options page



    Right-click within the main content of the Options popup (not the title bar) and select "Inspect". This will open the DevTools for the options page.



    For your panel or a page from within your extension loaded in a tab



    When the panel or tab is focused, you can open the DevTools by pressing F12 (or other shortcuts), or by opening the context menu (right-click) and selecting "Inspect".






    share|improve this answer


























    • @Mayken for popups is not working. Those alternatives are not available at least in ffx 55

      – gal007
      Jun 23 '17 at 13:29











    • @gal007, What are you not seeing? In which console? I'm seeing popup console.log() output just fine in Firefox Developer Edition v55b3 in the Browser Console, the Browser Toolbox and the Add-on Debugger. In Firefox Nightly v56, I also see popup console.log() output in all three tools. I did experience problems with the Browser Toolbox and Add-on Debugger when I tried to use them simultaneously in multiple instances of Firefox. However, they were broken completely (in all but the first instance started, when trying to use >1 instance of Firefox using those tools), not just for popup output.

      – Makyen
      Jun 28 '17 at 8:19
















    17














    Firefox



    In Firefox, your code works (outputs to console), as it is written in the question.



    If you are not seeing it in the console, then you are, probably, looking at the wrong console.



    Mozilla describes what extension output can be seen in which console in their Debugging page.



    Browser Console



    You should be using the Browser Console. You can access it from Tools➜Web Developer➜Browser Console (keyboard shortcut Ctrl-Shift-J, or Cmd-Shift-J on Mac).



    Browser Toolbox



    If you have it enabled, you could also use the Browser Toolbox console. You can access it from Tools➜Web Developer➜Browser Toolbox (keyboard shortcut Ctrl-Alt-Shift-I; On a Mac: Cmd-Alt-Shift-I).



    Add-on Debugger



    To debug your add-on you can use the Add-on Debugger. You can access it though about:debugging➞Debug.



    Web Console



    You, probably, are looking at the Web Console (keyboard shortcut F12) which is associated with only a single tab. This is what you want when debugging a webpage, but not an add-on. For a content script which is injected in that tab, the console.log() output will show up in this console. However, you will not see output from any other portion of your add-on (e.g. not content scripts in other tabs, not background scripts, etc.).



    Google Chrome



    Showing the correct console for your extension is a bit more complex in Chrome. Console output will show up in only one of multiple possible places, depending on from what context the console.log() was executed. Each of the following DevTools are independent of each other and are displayed in separate windows, or tabs. Displaying in the associated tab (bottom or side) is the default for the DevTools associated with web pages and content scripts, because those are specific to the tab. For the web page/content script DevTools, you have the option of having it displayed in its own separate window, or docked inside the tab (side or bottom).



    For your Background page



    As Srujan Reddy explained, you have to go through multiple selections on a drop-down menu, to get to the chrome://extensions page (or you can type that in by hand as the URL, or use a bookmark) then select both a checkbox ("Developer mode") and then click on the "background page" link. Then, you have to select the "Console" tab on the window that pops up.



    It is much easier to show what you have to do:
    Show console for extension on Google Chrome



    For your Content Scripts



    Output will be shown in the regular web console (in the web Developer Tools). You can open it by pressing F12 (or other shortcuts) in the webpage in which your content script was injected. Each web console will only show the output from the scripts injected in that tab.



    Doing the above with show the console.* output from your extension, but will result in the console JavaScript command line, debugger, etc. being in the context of the page, not the content script.



    If you want to use the console JavaScript command line in the context of the content scripts which are injected into a web page, you need to select your extension's content script context from the drop-down menu in the upper left of the Console window. This drop-down menu will normally start with the value "top". The drop down will have selections for each of the content script contexts (one per extension that has script(s) injected).



    For your Popup



    Right-click on your browserAction button and select "Inspect Popup". Alternately, right-click within the popup and select "Inspect". Either will open the DevTools for the popup page. The popup will be kept open under more conditions than it normally would, but will still be closed if you switch tabs, etc.



    For your Options page



    Right-click within the main content of the Options popup (not the title bar) and select "Inspect". This will open the DevTools for the options page.



    For your panel or a page from within your extension loaded in a tab



    When the panel or tab is focused, you can open the DevTools by pressing F12 (or other shortcuts), or by opening the context menu (right-click) and selecting "Inspect".






    share|improve this answer


























    • @Mayken for popups is not working. Those alternatives are not available at least in ffx 55

      – gal007
      Jun 23 '17 at 13:29











    • @gal007, What are you not seeing? In which console? I'm seeing popup console.log() output just fine in Firefox Developer Edition v55b3 in the Browser Console, the Browser Toolbox and the Add-on Debugger. In Firefox Nightly v56, I also see popup console.log() output in all three tools. I did experience problems with the Browser Toolbox and Add-on Debugger when I tried to use them simultaneously in multiple instances of Firefox. However, they were broken completely (in all but the first instance started, when trying to use >1 instance of Firefox using those tools), not just for popup output.

      – Makyen
      Jun 28 '17 at 8:19














    17












    17








    17







    Firefox



    In Firefox, your code works (outputs to console), as it is written in the question.



    If you are not seeing it in the console, then you are, probably, looking at the wrong console.



    Mozilla describes what extension output can be seen in which console in their Debugging page.



    Browser Console



    You should be using the Browser Console. You can access it from Tools➜Web Developer➜Browser Console (keyboard shortcut Ctrl-Shift-J, or Cmd-Shift-J on Mac).



    Browser Toolbox



    If you have it enabled, you could also use the Browser Toolbox console. You can access it from Tools➜Web Developer➜Browser Toolbox (keyboard shortcut Ctrl-Alt-Shift-I; On a Mac: Cmd-Alt-Shift-I).



    Add-on Debugger



    To debug your add-on you can use the Add-on Debugger. You can access it though about:debugging➞Debug.



    Web Console



    You, probably, are looking at the Web Console (keyboard shortcut F12) which is associated with only a single tab. This is what you want when debugging a webpage, but not an add-on. For a content script which is injected in that tab, the console.log() output will show up in this console. However, you will not see output from any other portion of your add-on (e.g. not content scripts in other tabs, not background scripts, etc.).



    Google Chrome



    Showing the correct console for your extension is a bit more complex in Chrome. Console output will show up in only one of multiple possible places, depending on from what context the console.log() was executed. Each of the following DevTools are independent of each other and are displayed in separate windows, or tabs. Displaying in the associated tab (bottom or side) is the default for the DevTools associated with web pages and content scripts, because those are specific to the tab. For the web page/content script DevTools, you have the option of having it displayed in its own separate window, or docked inside the tab (side or bottom).



    For your Background page



    As Srujan Reddy explained, you have to go through multiple selections on a drop-down menu, to get to the chrome://extensions page (or you can type that in by hand as the URL, or use a bookmark) then select both a checkbox ("Developer mode") and then click on the "background page" link. Then, you have to select the "Console" tab on the window that pops up.



    It is much easier to show what you have to do:
    Show console for extension on Google Chrome



    For your Content Scripts



    Output will be shown in the regular web console (in the web Developer Tools). You can open it by pressing F12 (or other shortcuts) in the webpage in which your content script was injected. Each web console will only show the output from the scripts injected in that tab.



    Doing the above with show the console.* output from your extension, but will result in the console JavaScript command line, debugger, etc. being in the context of the page, not the content script.



    If you want to use the console JavaScript command line in the context of the content scripts which are injected into a web page, you need to select your extension's content script context from the drop-down menu in the upper left of the Console window. This drop-down menu will normally start with the value "top". The drop down will have selections for each of the content script contexts (one per extension that has script(s) injected).



    For your Popup



    Right-click on your browserAction button and select "Inspect Popup". Alternately, right-click within the popup and select "Inspect". Either will open the DevTools for the popup page. The popup will be kept open under more conditions than it normally would, but will still be closed if you switch tabs, etc.



    For your Options page



    Right-click within the main content of the Options popup (not the title bar) and select "Inspect". This will open the DevTools for the options page.



    For your panel or a page from within your extension loaded in a tab



    When the panel or tab is focused, you can open the DevTools by pressing F12 (or other shortcuts), or by opening the context menu (right-click) and selecting "Inspect".






    share|improve this answer















    Firefox



    In Firefox, your code works (outputs to console), as it is written in the question.



    If you are not seeing it in the console, then you are, probably, looking at the wrong console.



    Mozilla describes what extension output can be seen in which console in their Debugging page.



    Browser Console



    You should be using the Browser Console. You can access it from Tools➜Web Developer➜Browser Console (keyboard shortcut Ctrl-Shift-J, or Cmd-Shift-J on Mac).



    Browser Toolbox



    If you have it enabled, you could also use the Browser Toolbox console. You can access it from Tools➜Web Developer➜Browser Toolbox (keyboard shortcut Ctrl-Alt-Shift-I; On a Mac: Cmd-Alt-Shift-I).



    Add-on Debugger



    To debug your add-on you can use the Add-on Debugger. You can access it though about:debugging➞Debug.



    Web Console



    You, probably, are looking at the Web Console (keyboard shortcut F12) which is associated with only a single tab. This is what you want when debugging a webpage, but not an add-on. For a content script which is injected in that tab, the console.log() output will show up in this console. However, you will not see output from any other portion of your add-on (e.g. not content scripts in other tabs, not background scripts, etc.).



    Google Chrome



    Showing the correct console for your extension is a bit more complex in Chrome. Console output will show up in only one of multiple possible places, depending on from what context the console.log() was executed. Each of the following DevTools are independent of each other and are displayed in separate windows, or tabs. Displaying in the associated tab (bottom or side) is the default for the DevTools associated with web pages and content scripts, because those are specific to the tab. For the web page/content script DevTools, you have the option of having it displayed in its own separate window, or docked inside the tab (side or bottom).



    For your Background page



    As Srujan Reddy explained, you have to go through multiple selections on a drop-down menu, to get to the chrome://extensions page (or you can type that in by hand as the URL, or use a bookmark) then select both a checkbox ("Developer mode") and then click on the "background page" link. Then, you have to select the "Console" tab on the window that pops up.



    It is much easier to show what you have to do:
    Show console for extension on Google Chrome



    For your Content Scripts



    Output will be shown in the regular web console (in the web Developer Tools). You can open it by pressing F12 (or other shortcuts) in the webpage in which your content script was injected. Each web console will only show the output from the scripts injected in that tab.



    Doing the above with show the console.* output from your extension, but will result in the console JavaScript command line, debugger, etc. being in the context of the page, not the content script.



    If you want to use the console JavaScript command line in the context of the content scripts which are injected into a web page, you need to select your extension's content script context from the drop-down menu in the upper left of the Console window. This drop-down menu will normally start with the value "top". The drop down will have selections for each of the content script contexts (one per extension that has script(s) injected).



    For your Popup



    Right-click on your browserAction button and select "Inspect Popup". Alternately, right-click within the popup and select "Inspect". Either will open the DevTools for the popup page. The popup will be kept open under more conditions than it normally would, but will still be closed if you switch tabs, etc.



    For your Options page



    Right-click within the main content of the Options popup (not the title bar) and select "Inspect". This will open the DevTools for the options page.



    For your panel or a page from within your extension loaded in a tab



    When the panel or tab is focused, you can open the DevTools by pressing F12 (or other shortcuts), or by opening the context menu (right-click) and selecting "Inspect".







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jul 16 '17 at 9:52

























    answered Aug 12 '16 at 14:58









    MakyenMakyen

    20.6k83971




    20.6k83971













    • @Mayken for popups is not working. Those alternatives are not available at least in ffx 55

      – gal007
      Jun 23 '17 at 13:29











    • @gal007, What are you not seeing? In which console? I'm seeing popup console.log() output just fine in Firefox Developer Edition v55b3 in the Browser Console, the Browser Toolbox and the Add-on Debugger. In Firefox Nightly v56, I also see popup console.log() output in all three tools. I did experience problems with the Browser Toolbox and Add-on Debugger when I tried to use them simultaneously in multiple instances of Firefox. However, they were broken completely (in all but the first instance started, when trying to use >1 instance of Firefox using those tools), not just for popup output.

      – Makyen
      Jun 28 '17 at 8:19



















    • @Mayken for popups is not working. Those alternatives are not available at least in ffx 55

      – gal007
      Jun 23 '17 at 13:29











    • @gal007, What are you not seeing? In which console? I'm seeing popup console.log() output just fine in Firefox Developer Edition v55b3 in the Browser Console, the Browser Toolbox and the Add-on Debugger. In Firefox Nightly v56, I also see popup console.log() output in all three tools. I did experience problems with the Browser Toolbox and Add-on Debugger when I tried to use them simultaneously in multiple instances of Firefox. However, they were broken completely (in all but the first instance started, when trying to use >1 instance of Firefox using those tools), not just for popup output.

      – Makyen
      Jun 28 '17 at 8:19

















    @Mayken for popups is not working. Those alternatives are not available at least in ffx 55

    – gal007
    Jun 23 '17 at 13:29





    @Mayken for popups is not working. Those alternatives are not available at least in ffx 55

    – gal007
    Jun 23 '17 at 13:29













    @gal007, What are you not seeing? In which console? I'm seeing popup console.log() output just fine in Firefox Developer Edition v55b3 in the Browser Console, the Browser Toolbox and the Add-on Debugger. In Firefox Nightly v56, I also see popup console.log() output in all three tools. I did experience problems with the Browser Toolbox and Add-on Debugger when I tried to use them simultaneously in multiple instances of Firefox. However, they were broken completely (in all but the first instance started, when trying to use >1 instance of Firefox using those tools), not just for popup output.

    – Makyen
    Jun 28 '17 at 8:19





    @gal007, What are you not seeing? In which console? I'm seeing popup console.log() output just fine in Firefox Developer Edition v55b3 in the Browser Console, the Browser Toolbox and the Add-on Debugger. In Firefox Nightly v56, I also see popup console.log() output in all three tools. I did experience problems with the Browser Toolbox and Add-on Debugger when I tried to use them simultaneously in multiple instances of Firefox. However, they were broken completely (in all but the first instance started, when trying to use >1 instance of Firefox using those tools), not just for popup output.

    – Makyen
    Jun 28 '17 at 8:19













    4














    Which console are you viewing in for the logs?



    If you are viewing console on a tab, then that is the wrong place.



    Open settings / Extensions or in a new tab type



    chrome://extensions


    Under your extension click on "background page" link which is where you can watch for logs



    **Make sure Developer mode is checked






    share|improve this answer




























      4














      Which console are you viewing in for the logs?



      If you are viewing console on a tab, then that is the wrong place.



      Open settings / Extensions or in a new tab type



      chrome://extensions


      Under your extension click on "background page" link which is where you can watch for logs



      **Make sure Developer mode is checked






      share|improve this answer


























        4












        4








        4







        Which console are you viewing in for the logs?



        If you are viewing console on a tab, then that is the wrong place.



        Open settings / Extensions or in a new tab type



        chrome://extensions


        Under your extension click on "background page" link which is where you can watch for logs



        **Make sure Developer mode is checked






        share|improve this answer













        Which console are you viewing in for the logs?



        If you are viewing console on a tab, then that is the wrong place.



        Open settings / Extensions or in a new tab type



        chrome://extensions


        Under your extension click on "background page" link which is where you can watch for logs



        **Make sure Developer mode is checked







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Aug 12 '16 at 9:00









        Srujan ReddySrujan Reddy

        505319




        505319























            1














            Yes for Chrome you have to click the background page link mentioned, but it won't be there unless you set it to be persistent:



            "background": {
            "persistent": true,
            "scripts": ["background.js"]
            }





            share|improve this answer





















            • 1





              This is not, necessarily, accurate. At least with the code exactly as in the question, when loaded using "Load unpackaged extension...", setting "persistent": true is not required to have the "background page" link showing.

              – Makyen
              Aug 13 '16 at 20:32
















            1














            Yes for Chrome you have to click the background page link mentioned, but it won't be there unless you set it to be persistent:



            "background": {
            "persistent": true,
            "scripts": ["background.js"]
            }





            share|improve this answer





















            • 1





              This is not, necessarily, accurate. At least with the code exactly as in the question, when loaded using "Load unpackaged extension...", setting "persistent": true is not required to have the "background page" link showing.

              – Makyen
              Aug 13 '16 at 20:32














            1












            1








            1







            Yes for Chrome you have to click the background page link mentioned, but it won't be there unless you set it to be persistent:



            "background": {
            "persistent": true,
            "scripts": ["background.js"]
            }





            share|improve this answer















            Yes for Chrome you have to click the background page link mentioned, but it won't be there unless you set it to be persistent:



            "background": {
            "persistent": true,
            "scripts": ["background.js"]
            }






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 13 '16 at 2:50

























            answered Aug 13 '16 at 2:45









            M. PhelanM. Phelan

            114




            114








            • 1





              This is not, necessarily, accurate. At least with the code exactly as in the question, when loaded using "Load unpackaged extension...", setting "persistent": true is not required to have the "background page" link showing.

              – Makyen
              Aug 13 '16 at 20:32














            • 1





              This is not, necessarily, accurate. At least with the code exactly as in the question, when loaded using "Load unpackaged extension...", setting "persistent": true is not required to have the "background page" link showing.

              – Makyen
              Aug 13 '16 at 20:32








            1




            1





            This is not, necessarily, accurate. At least with the code exactly as in the question, when loaded using "Load unpackaged extension...", setting "persistent": true is not required to have the "background page" link showing.

            – Makyen
            Aug 13 '16 at 20:32





            This is not, necessarily, accurate. At least with the code exactly as in the question, when loaded using "Load unpackaged extension...", setting "persistent": true is not required to have the "background page" link showing.

            – Makyen
            Aug 13 '16 at 20:32


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f38913799%2fgoogle-chrome-firefox-do-not-see-extension-output-in-console%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'