Confirmed users
497
edits
m ([master 798086d] Create 'General Conventions' section.) |
([listTabs 6618355] Document browser tab actor interactions.) |
||
| Line 440: | Line 440: | ||
{ "from":"root", "applicationType":"browser", "traits":<i>traits</i> } | { "from":"root", "applicationType":"browser", "traits":<i>traits</i> } | ||
== Listing | == Listing Browser Tabs == | ||
To get a list of the | To get a list of the tabs currently present in a browser, a client sends the root actor a request of the form: | ||
{ "to":"root", "type":" | { "to":"root", "type":"listTabs" } | ||
The | The root actor replies: | ||
{ "from":"root", " | { "from":"root", "tabs":[<i>tab</i>, ...], "selected":<i>selected</i> } | ||
where each <i>tab</i> describes a single open tab, and <i>selected</i> is the index in the array of tabs of the currently selected tab. This form may have other properties describing other global actors; for one example, see [[#Chrome_Debugging|Chrome Debugging]]. | |||
Each <i>tab</i> has the form: | |||
<i> | { "actor":<i>tabActor</i>, "title":<i>title</i>, "url":<i>URL</i> } | ||
where <i>tabActor</i> is the name of an actor representing the tab, and <i>title</i> and <i>URL</i> are the title and URL of the web page currently visible in that tab. This form may have other properties describing other tab-specific actors. | |||
To attach to a <i>tabActor</i>, a client sends a message of the form: | |||
{ "to":<i>tabActor</i>, "type":"attach" } | |||
The tab actor replies: | |||
<i> | { "from":<i>tabActor</i>, "type":"tabAttached", "threadActor":<i>tabThreadActor</i> } | ||
<i> | where <i>tabThreadActor</i> is the name of a thread-like actor representing the tab's current content. If the user navigates the tab, <i>tabThreadActor</i> switches to the new content; we do not create a separate thread-like actor each page the tab visits. | ||
If the user closes the tab before the client attaches to it, <i>tabActor</i> replies: | |||
{ "from":<i>tabActor</i>, "type":"exited" } | |||
When the client is no longer interested in interacting with the tab, the client can request: | |||
{ "to":<i>tabActor</i>, "type":"detach" } | |||
The <i>tabActor</i> replies: | |||
{ "from":<i>tabActor</i>, "type":"detached" } | |||
If the client was not already attached to <i>tabActor</i>, <i>tabActor</i> sends an error reply of the form: | |||
{ "from":<i>tabActor</i>, "error":"wrongState" } | |||
While the client is attached, <i>tabActor</i> sends unsolicited notifications to the client whenever the user navigates the tab to a new page. When navigation begins, <i>tabActor</i> sends a packet of the form: | |||
{ "from":<i>tabActor</i>, "type":"tabNavigated", "state":"start", | |||
"url":<i>newURL</i> } | |||
This indicates that the tab has begun navigating to <i>newURL</i>; JavaScript execution in the tab's prior page is suspended. When navigation is complete, <i>tabActor</i> sends a packet of the form: | |||
{ "from":<i>tabActor</i>, "type":"tabNavigated", "state":"stop", | |||
"url":<i>newURL</i>, "title":<i>newTitle</i> } | |||
where <i>newURL</i> and <i>newTitle</i> are the URL and title of the page the tab is now showing. The <i>tabThreadActor</i> given in the response to the original <code>"attach"</code> request is now debugging the new page's code. | |||
If the user closes a tab to which the client is attached, its <i>tabActor</i> sends an unsolicited packet of the form: | |||
{ "from":<i>tabActor</i>, "type":"tabDetached" } | |||
The client is now detached from the tab. | |||
== Chrome Debugging == | |||
If the server supports debugging chrome code, the root actor's reply to a <code>"listTabs"</code> request includes a property named <code>"chromeDebugger"</code>, whose value is the name of a thread-like actor to which the client can attach to debug chrome code. | |||
= Interacting with Thread-Like Actors = | = Interacting with Thread-Like Actors = | ||
| Line 1,006: | Line 1,040: | ||
<!-- Local Variables: --> | <!-- Local Variables: --> | ||
<!-- eval: (visual-line-mode) --> | <!-- eval: (visual-line-mode) --> | ||
<!-- page-delimiter: "^=" --> | |||
<!-- End: --> | <!-- End: --> | ||