devtools: api to inspect service worker for current webcontents

This commit is contained in:
deepak1556 2015-05-18 19:19:33 +05:30
parent 827741a9c6
commit 46d80e8f05
4 changed files with 18 additions and 0 deletions

View file

@ -615,6 +615,17 @@ void WebContents::UnregisterServiceWorker(
callback);
}
void WebContents::InspectServiceWorker() {
for (const auto& agent_host : content::DevToolsAgentHost::GetOrCreateAll()) {
if (agent_host->GetType() ==
content::DevToolsAgentHost::TYPE_SERVICE_WORKER) {
OpenDevTools();
storage_->AttachTo(agent_host);
break;
}
}
}
mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
if (template_.IsEmpty())
@ -657,6 +668,7 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
.SetMethod("hasServiceWorker", &WebContents::HasServiceWorker)
.SetMethod("unregisterServiceWorker",
&WebContents::UnregisterServiceWorker)
.SetMethod("inspectServiceWorker", &WebContents::InspectServiceWorker)
.Build());
return mate::ObjectTemplateBuilder(

View file

@ -68,6 +68,7 @@ class WebContents : public mate::EventEmitter,
void InspectElement(int x, int y);
void HasServiceWorker(const base::Callback<void(bool)>&);
void UnregisterServiceWorker(const base::Callback<void(bool)>&);
void InspectServiceWorker();
// Editing commands.
void Undo();

View file

@ -268,6 +268,7 @@ registerWebViewElement = ->
"replaceMisspelling"
"send"
"getId"
"inspectServiceWorker"
]
# Forward proto.foo* method calls to WebViewImpl.foo*.

View file

@ -226,6 +226,10 @@ Returns whether guest page has a devtools window attached.
Starts inspecting element at position (`x`, `y`) of guest page.
### `<webview>`.inspectServiceWorker()
Opens the devtools for the service worker context present in the guest page.
### `<webview>`.undo()
Executes editing command `undo` in page.