How do you use the chrome.tabs module to create a new tab? I have
already declared the "tabs" permission in manifest.json, and this is
how my popup.html looks like.
<script type="text/javascript">
function createTab() {
chrome.tabs.create();
}
</script>
<body>
<a onclick="createTab();">Click me</a>
</body>
But it doesn't work. I tried looking at samples in
http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/tabs/
but they're too complicated and I don't have the time to figure out
the essential code for tab creation.
Cheers
Fabian
--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.
Just curious, here (http://code.google.com/chrome/extensions/
tabs.html#method-create) it states that all four windowId, index, url
& selected are optional. So how come it doesn't work when I don't
specify one of them?
Ken
Optional arguments can be set to null or undefined. If they are, a
default value is used. Issue 29215 tracks work allowing optional
arguments to be omitted.
Sam
On Mar 23, 9:36 pm, Sam Kerner <sker...@google.com> wrote:
> On Tue, Mar 23, 2010 at 8:51 AM, fterh <fabiani...@gmail.com> wrote:
> > Thanks, though I figured that out already.
>
> > Just curious, here (http://code.google.com/chrome/extensions/
> > tabs.html#method-create) it states that all four windowId, index, url
> > & selected are optional. So how come it doesn't work when I don't
> > specify one of them?
>
> Optional arguments can be set to null or undefined. If they are, a
> default value is used. Issue 29215 tracks work allowing optional
> arguments to be omitted.
>
> Sam
>
>
>
>
>
> > --
> > You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to chromium-extensions+unsubscr...@chromium.org.
> To post to this group, send email to chromium-...@chromium.org.
> To unsubscribe from this group, send email to chromium-extens...@chromium.org.
We have an issues tracker to record work to be done. You can see
issue 29215 here:
http://code.google.com/p/chromium/issues/detail?id=29215
The open issue means we know about the problem, and plan to fix it,
but it has not yet been fixed.
Sam
> To post to this group, send email to chromium-...@chromium.org.
> To unsubscribe from this group, send email to chromium-extens...@chromium.org.
I tried:
chrome.tabs.create(null);
chrome.tabs.create({null});
chrome.tabs.create({url:null});
but none of them worked. The last one crashed the extension though.
On Mar 23, 9:36 pm, Sam Kerner <sker...@google.com> wrote:
> On Tue, Mar 23, 2010 at 8:51 AM, fterh <fabiani...@gmail.com> wrote:
> > Thanks, though I figured that out already.
>
> > Just curious, here (http://code.google.com/chrome/extensions/
> > tabs.html#method-create) it states that all four windowId, index, url
> > & selected are optional. So how come it doesn't work when I don't
> > specify one of them?
>
> Optional arguments can be set to null or undefined. If they are, a
> default value is used. Issue 29215 tracks work allowing optional
> arguments to be omitted.
>
> Sam
>
>
>
>
>
> > --
> > You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to chromium-extensions+unsubscr...@chromium.org.
The docs* give the following function for creating a tab:
chrome.tabs.create(object createProperties, function callback)
The first argument is not optional, so you should not call the
function without arguments. All properties of createProperties are
optional, so chrome.tabs.create({}, function(){}); should work.
Stepping back, why do you need to call chrome.tabs.create() without
arguments?
*: http://code.google.com/chrome/extensions/tabs.html
>
> I tried:
>
> chrome.tabs.create(null);
> chrome.tabs.create({null});
> chrome.tabs.create({url:null});
>
> but none of them worked. The last one crashed the extension though.
That last one should error out without crashing. Would you mind
filing a bug at http://crbug.com/?
Sam
>
> On Mar 23, 9:36 pm, Sam Kerner <sker...@google.com> wrote:
>> On Tue, Mar 23, 2010 at 8:51 AM, fterh <fabiani...@gmail.com> wrote:
>> > Thanks, though I figured that out already.
>>
>> > Just curious, here (http://code.google.com/chrome/extensions/
>> > tabs.html#method-create) it states that all four windowId, index, url
>> > & selected are optional. So how come it doesn't work when I don't
>> > specify one of them?
>>
>> Optional arguments can be set to null or undefined. If they are, a
>> default value is used. Issue 29215 tracks work allowing optional
>> arguments to be omitted.
>>
>> Sam
>>
>>
>>
>>
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
>> > To post to this group, send email to chromium-extensi...@chromium.org.
>> > To unsubscribe from this group, send email to chromium-extensions+unsubscr...@chromium.org.
>> > For more options, visit this group athttp://groups.google.com/a/chromium.org/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 chromium-...@chromium.org.
> To unsubscribe from this group, send email to chromium-extens...@chromium.org.
> That last one should error out without crashing. Would you mind> filing a bug at http://crbug.com/?I don't think we consider this a bug.We try to be extra careful in validating the parameters passed in to avoid creating security issues in the extension system. So, while you can leave the URL parameter out (since it is optional) -- but if you specify it, it can not be NULL.We have a macro (EXTENSION_FUNCTION_VALIDATE) whose purpose is to validate the parameters and crash the extension when it sends garbage parameters and that's what is happening here.
We're getting a bunch off reviews saying our extension is crashing at
random, but we cannot recreate the crash ourselves.
What should we tell our users to send us so we can get information
about the cause of the crash?
On Mar 27, 7:10 am, Erik Kay <erik...@chromium.org> wrote:
> On Wed, Mar 24, 2010 at 9:27 AM, Finnur Thorarinsson <fin...@chromium.org>wrote:
>
> > > That last one should error out without crashing. Would you mind
> > > filing a bug athttp://crbug.com/?
>
> > I don't think we consider this a bug.
>
> > We try to be extra careful in validating the parameters passed in to avoid
> > creating security issues in the extension system. So, while you can leave
> > the URL parameter out (since it is optional) -- but if you specify it, it
> > can not be NULL.
>
> > We have a macro (EXTENSION_FUNCTION_VALIDATE) whose purpose is to validate
> > the parameters and crash the extension when it sends garbage parameters and
> > that's what is happening here.
>
> Just to be clear, this isn't a reason for us to crash. This crash behavior
> is meant to be a last line of defense against a compromised renderer, and it
> shouldn't be possible for extension authors to trigger it under normal
> conditions. If they are, then it's the fault of our renderer-side JS
> validation code, not the extension author.
>
> If you ever see a crash from using the API, even incorrectly, please file a
> bug so that we're aware of the issue. This isn't desired behavior in any
> case.
>
> Erik
>
>
>
> > I second what Sam said. What are you trying to do? The create function
> > defaults to the New Tab page if you don't specify a url. And if you don't
> > want to load a url and you don't want the new tab page then at a minimum you
> > need to specify url:"about:blank" to open a blank tab.
>
> > On Wed, Mar 24, 2010 at 07:46, Sam Kerner <sker...@google.com> wrote:
>
> >> On Wed, Mar 24, 2010 at 7:25 AM, fterh <fabiani...@gmail.com> wrote:
> >> > How do you create a tab without passing any arguments?
>
> >> The docs* give the following function for creating a tab:
>
> >> chrome.tabs.create(object createProperties, function callback)
>
> >> The first argument is not optional, so you should not call the
> >> function without arguments. All properties of createProperties are
> >> optional, so chrome.tabs.create({}, function(){}); should work.
>
> >> Stepping back, why do you need to call chrome.tabs.create() without
> >> arguments?
>
> >> *:http://code.google.com/chrome/extensions/tabs.html
>
> >> > I tried:
>
> >> > chrome.tabs.create(null);
> >> > chrome.tabs.create({null});
> >> > chrome.tabs.create({url:null});
>
> >> > but none of them worked. The last one crashed the extension though.
>
> >> That last one should error out without crashing. Would you mind
> >> filing a bug athttp://crbug.com/?
>
> >> Sam
>
> >> > On Mar 23, 9:36 pm, Sam Kerner <sker...@google.com> wrote:
> >> >> On Tue, Mar 23, 2010 at 8:51 AM, fterh <fabiani...@gmail.com> wrote:
> >> >> > Thanks, though I figured that out already.
>
> >> >> > Just curious, here (http://code.google.com/chrome/extensions/
> >> >> > tabs.html#method-create) it states that all four windowId, index, url
> >> >> > & selected are optional. So how come it doesn't work when I don't
> >> >> > specify one of them?
>
> >> >> Optional arguments can be set to null or undefined. If they are, a
> >> >> default value is used. Issue 29215 tracks work allowing optional
> >> >> arguments to be omitted.
>
> >> >> Sam
>
> >> >> > --
> >> >> > You received this message because you are subscribed to the Google
> >> Groups "Chromium-extensions" group.
> >> >> > To post to this group, send email to
> >> chromium-extensi...@chromium.org.
> >> >> > To unsubscribe from this group, send email to
> >> chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
> >> .
> >> >> > For more options, visit this group athttp://
> >> groups.google.com/a/chromium.org/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 chromium-extensi...@chromium.org.
> >> > To unsubscribe from this group, send email to
> >> chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
> >> .
> >> > For more options, visit this group at
> >>http://groups.google.com/a/chromium.org/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 chromium-extensi...@chromium.org.
> >> To unsubscribe from this group, send email to
> >> chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/a/chromium.org/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 chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
*Actually I found a bug in the sqlite database handler I'm using that
may have also been the cause of the crashes. I'm currently trying to
recreate it and if so will create a proper bug report for the chromium
team.
> > <chromium-extensions%2Bunsubscr...@chromium.org<chromium-extensions%252Bunsubscr...@chromium.org>
>
> > > >> .
> > > >> >> > For more options, visit this group athttp://
> > > >> groups.google.com/a/chromium.org/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
> > chromium-extensi...@chromium.org.
> > > >> > To unsubscribe from this group, send email to
> > > >> chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
> > <chromium-extensions%2Bunsubscr...@chromium.org<chromium-extensions%252Bunsubscr...@chromium.org>
>
> > > >> .
> > > >> > For more options, visit this group at
>
> >http://groups.google.com/a/chromium.org/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 chromium-extensi...@chromium.org
> > .
> > > >> To unsubscribe from this group, send email to
> > > >> chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
> > <chromium-extensions%2Bunsubscr...@chromium.org<chromium-extensions%252Bunsubscr...@chromium.org>
>
> > > >> .
> > > >> For more options, visit this group at
>
> >http://groups.google.com/a/chromium.org/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 chromium-extensi...@chromium.org.
> > > > To unsubscribe from this group, send email to
> > > > chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
> > <chromium-extensions%2Bunsubscr...@chromium.org<chromium-extensions%252Bunsubscr...@chromium.org>
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.