Skip to content

Commit

Permalink
Add a context parameter for browsingContext.create
Browse files Browse the repository at this point in the history
This is based on @jgraham's suggestion:
#133 (comment)

Co-authored-by: Julian Descottes <jdescottes@mozilla.com>
Co-authored-by: Maksim Sadym <69349599+sadym-chromium@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 5, 2022
1 parent 01c8d75 commit 7aab2a4
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2876,7 +2876,8 @@ The <dfn export for=commands>browsingContext.create</dfn> command creates a new
BrowsingContextCreateType = "tab" / "window"

BrowsingContextCreateParameters = {
type: BrowsingContextCreateType
type: BrowsingContextCreateType,
?referenceContext: BrowsingContext
}
</pre>
</dd>
Expand All @@ -2896,26 +2897,46 @@ The [=remote end steps=] with |command parameters| are:
1. Let |type| be the value of the <code>type</code> field of
|command parameters|.

1. Let |reference context id| be the value of the <code>referenceContext</code>
field of |command parameters|, if present, or null otherwise.

1. If |reference context id| is not null, let |reference context| be the
result of [=trying=] to [=get a browsing context=] with
|reference context id|. Otherwise let |reference context| be null.

1. If |reference context| is not null and is not a [=top-level browsing context=],
return [=error=] with [=error code=] [=invalid argument=].

1. If the implementation is unable to create a new browsing context for any
reason then return [=error=] with [=code=] [=unsupported operation=].

<!-- This is based on step 5 of https://w3c.github.io/webdriver/#new-window,
but without using the "current browsing context" concept. -->
1. Create a new [=top-level browsing context=] by running the [=window open
steps=] with <var ignore>url</var> set to "<code>about:blank</code>",
<var ignore>target</var> set to the empty string, and
<var ignore>features</var> set to "<code>noopener</code>". This must be
done without invoking the [=/focusing steps=] for the created browsing
context. If |type| is "<code>tab</code>", and the implementation supports
multiple browsing contexts in the same OS window, the new browsing context
should share an OS window with any other [=top-level browsing context=]. If
|type| is "<code>window</code>", and the implementation supports multiple
browsing contexts in separate OS windows, the created browsing context
should be in a new OS window. In all other cases the details of how the
browsing context is presented to the user are implementation defined.

Issue: HTML's [=window open steps=] depend on the "entry global object"
and WebDriver's <a href="https://w3c.github.io/webdriver/#new-window">New
Window</a> command depends on the "current browsing context". Given that we
don't have any such implicit context here, what OS window should new tabs
be opened in?
context. Which OS window the new [=/browsing context=] is created in
depends on |type| and |reference context|:

* If |type| is "<code>tab</code>" and the implementation supports
multiple browsing contexts in the same OS window:

* The new browsing context should reuse an existing OS window, if any.

* If |reference context| is not null, the new browsing context should
reuse the window containing |reference context|, if any. If the top
level browsing contexts inside an OS window have a definite ordering,
the new created top level browsing context should be immediately after
|reference context|'s [=top level browsing context=] in that ordering.

* If |type| is "<code>window</code>", and the implementation supports
multiple browsing contexts in separate OS windows, the created browsing
context should be in a new OS window.

* Otherwise, the details of how the browsing context is presented to the
user are implementation defined.

1. Let |context id| be the [=browsing context id=] of the newly created
[=/browsing context=].
Expand Down

0 comments on commit 7aab2a4

Please sign in to comment.