My use case is simple - to let the background page know that a user has clicked on the browserAction button. I would use chrome.browserAction.onClicked.addListener() - but for some reason it works only when there is no popup specified in the manifest. Thus I have to do a workaround - write a script in the popup.html page that would notify the background page (either using this way I wrote or another hack like exporting a method of the main background page object).
On Tue, Jan 19, 2010 at 10:50 PM, Rafael Weinstein <[email protected]>wrote: > Hi Andrey, > > As you observe, the Event dispatch function is not a part of the > public API, so it cannot be depending upon (future implementation may > change it's behavior). > > Can you explain your use case? Why are you trying to simulate a click > to the browserAction? > > As to your second question (why do you have to call the background > pages event.dispatch), the reason is that each page has it's own copy > of that event object, with it's own set of listeners. The > event.dispatch() as receiver of event data from the browser, not a > sender. It merely routes the event information to the listeners in > that context. > > There is no way to "fire" events from javascript such that their > behavior would mimic the behavior as if the event had been generated > "organically" from the browser. > > Hope this helps. > > Cheers > Rafael > > On Mon, Jan 18, 2010 at 4:49 AM, Andrey <[email protected]> wrote: > > Hi Team, > > Can I use the following code to simulate a browser action click: > > > > chrome.tabs.getSelected(null, function(tab) { > > var backgroundPage = chrome.extension.getBackgroundPage(); > > backgroundPage.chrome.browserAction.onClicked.dispatch(tab); > > }); > > > > This code does work, but AFAIU, the > > chrome.browserAction.onClicked.dispatch() is NOT a documented API, is > > it? But still I'll ask, can I rely on it? :) > > > > And, as a side note: notice that I have to use the backgroundPage's > > chrome object to do the trick when the code is being run inside a > > browserAction's popup page. Bother to explain why the direct > > chrome.browserAction.onClicked.dispatch() would not work? :) > > > > Thanks. > > > > -- > > You received this message because you are subscribed to the Google Groups > "Chromium-extensions" group. > > To post to this group, send email to > [email protected]. > > To unsubscribe from this group, send email to > [email protected]<chromium-extensions%[email protected]> > . > > For more options, visit this group at > http://groups.google.com/group/chromium-extensions?hl=en. > > > > > > > > >--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en.
