devtools: api to inspect service worker for current webcontents
This commit is contained in:
parent
827741a9c6
commit
46d80e8f05
4 changed files with 18 additions and 0 deletions
|
@ -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(
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -268,6 +268,7 @@ registerWebViewElement = ->
|
|||
"replaceMisspelling"
|
||||
"send"
|
||||
"getId"
|
||||
"inspectServiceWorker"
|
||||
]
|
||||
|
||||
# Forward proto.foo* method calls to WebViewImpl.foo*.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue