console.log not working with Context Menus Sample

361 views
Skip to first unread message

Dave

unread,
Dec 26, 2010, 10:02:14 AM12/26/10
to Chromium Apps
I downloaded the sample context menu extension from
http://code.google.com/chrome/extensions/samples.html. None of the
console.log messages appear in the Javascript console. I have other
extensions and console.log works fine (but they do not use
chrome.contextMenus). Is this a bug? I am running Google Chrome
8.0.552.224).

Thanks!

PhistucK

unread,
Dec 26, 2010, 12:14:11 PM12/26/10
to Dave, Chromium Apps
Did you look at the JavaScript console of the background page?

PhistucK

Dave

unread,
Dec 26, 2010, 2:16:08 PM12/26/10
to Chromium Apps
I replaced sample.js with this code:

console.log('Start Code');
chrome.contextMenus.create( {"title":"New Item", "contexts": ["all"],
"onclick": myOnClick} );
function myOnClick() {console.log('myOnClick called');}

If I load background.html (Control-O) and reload the page, I will see
"Start Code", but I also get this error:

Uncaught TypeError: Cannot call method 'create' of undefined

In the background tab, I do not see the changes to the context menu
(even after using Reload on the Extensions tab).
Other tabs (e.g. viewing google.com) will show the item in the context
menu, but selecting it will not show any message in the console.

I don't understand this error since the method appears to be called
and results in a new item (on other pages/tabs).

Am I missing something?

Thanks for the help.

On Dec 26, 12:14 pm, PhistucK <phist...@gmail.com> wrote:
> Did you look at the JavaScript console of the background page?
>
> ☆*PhistucK*

Dave

unread,
Dec 26, 2010, 3:11:20 PM12/26/10
to Chromium Apps
I found my problem. I was using Control-O to open background.html.
This will not work. If you click on background.html in the Extension
tabs, then the new window will work as expected.
Reply all
Reply to author
Forward
0 new messages