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);
|
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(
|
mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
|
||||||
v8::Isolate* isolate) {
|
v8::Isolate* isolate) {
|
||||||
if (template_.IsEmpty())
|
if (template_.IsEmpty())
|
||||||
|
@ -657,6 +668,7 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
|
||||||
.SetMethod("hasServiceWorker", &WebContents::HasServiceWorker)
|
.SetMethod("hasServiceWorker", &WebContents::HasServiceWorker)
|
||||||
.SetMethod("unregisterServiceWorker",
|
.SetMethod("unregisterServiceWorker",
|
||||||
&WebContents::UnregisterServiceWorker)
|
&WebContents::UnregisterServiceWorker)
|
||||||
|
.SetMethod("inspectServiceWorker", &WebContents::InspectServiceWorker)
|
||||||
.Build());
|
.Build());
|
||||||
|
|
||||||
return mate::ObjectTemplateBuilder(
|
return mate::ObjectTemplateBuilder(
|
||||||
|
|
|
@ -68,6 +68,7 @@ class WebContents : public mate::EventEmitter,
|
||||||
void InspectElement(int x, int y);
|
void InspectElement(int x, int y);
|
||||||
void HasServiceWorker(const base::Callback<void(bool)>&);
|
void HasServiceWorker(const base::Callback<void(bool)>&);
|
||||||
void UnregisterServiceWorker(const base::Callback<void(bool)>&);
|
void UnregisterServiceWorker(const base::Callback<void(bool)>&);
|
||||||
|
void InspectServiceWorker();
|
||||||
|
|
||||||
// Editing commands.
|
// Editing commands.
|
||||||
void Undo();
|
void Undo();
|
||||||
|
|
|
@ -268,6 +268,7 @@ registerWebViewElement = ->
|
||||||
"replaceMisspelling"
|
"replaceMisspelling"
|
||||||
"send"
|
"send"
|
||||||
"getId"
|
"getId"
|
||||||
|
"inspectServiceWorker"
|
||||||
]
|
]
|
||||||
|
|
||||||
# Forward proto.foo* method calls to WebViewImpl.foo*.
|
# 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.
|
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()
|
### `<webview>`.undo()
|
||||||
|
|
||||||
Executes editing command `undo` in page.
|
Executes editing command `undo` in page.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue