Commit 1e506d91 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

Report gated API status on frameNavigated

This CL adds a list of available APIs to the frameNavigated event,
which are then shown in DevTools.

Bug: chromium:1139899
Change-Id: Ic0b44e869901113d44df165f3f3db492721a8510
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2514378Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823952}
parent 98d0295a
......@@ -5941,6 +5941,13 @@ domain Page
# The cross-origin isolation feature is disabled.
NotIsolatedFeatureDisabled
experimental type GatedAPIFeatures extends string
enum
SharedArrayBuffers
SharedArrayBuffersTransferAllowed
PerformanceMeasureMemory
PerformanceProfile
# Information about the Frame on the page.
type Frame extends object
properties
......@@ -5973,6 +5980,8 @@ domain Page
experimental SecureContextType secureContextType
# Indicates whether this is a cross origin isolated context.
experimental CrossOriginIsolatedContextType crossOriginIsolatedContextType
# Indicated which gated APIs / features are available.
experimental array of GatedAPIFeatures gatedAPIFeatures
# Information about the Resource on the page.
experimental type FrameResource extends object
......
......@@ -41,6 +41,7 @@
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/document_timing.h"
#include "third_party/blink/renderer/core/dom/dom_node_ids.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
......@@ -1089,6 +1090,28 @@ CreateProtocolCrossOriginIsolatedContextType(ExecutionContext* context) {
return protocol::Page::CrossOriginIsolatedContextTypeEnum::
NotIsolatedFeatureDisabled;
}
std::unique_ptr<std::vector<protocol::Page::GatedAPIFeatures>>
CreateGatedAPIFeaturesArray(LocalDOMWindow* window) {
auto features =
std::make_unique<std::vector<protocol::Page::GatedAPIFeatures>>();
// SABs are available if at least one of the following is true:
// - features::kWebAssemblyThreads enabled
// - features::kSharedArrayBuffer enabled
// - agent has the cross-origin isolated bit (but not necessarily the
// capability)
if (RuntimeEnabledFeatures::SharedArrayBufferEnabled(window) ||
Agent::IsCrossOriginIsolated()) {
features->push_back(
protocol::Page::GatedAPIFeaturesEnum::SharedArrayBuffers);
}
if (window->SharedArrayBufferTransferAllowed()) {
features->push_back(protocol::Page::GatedAPIFeaturesEnum::
SharedArrayBuffersTransferAllowed);
}
// TODO(chromium:1139899): Report availablility of performance.measureMemory()
// and performance.profile() once they are gated/available, respectively.
return features;
}
} // namespace
std::unique_ptr<protocol::Page::Frame> InspectorPageAgent::BuildObjectForFrame(
......@@ -1112,6 +1135,7 @@ std::unique_ptr<protocol::Page::Frame> InspectorPageAgent::BuildObjectForFrame(
.GetSecureContextModeExplanation()))
.setCrossOriginIsolatedContextType(
CreateProtocolCrossOriginIsolatedContextType(frame->DomWindow()))
.setGatedAPIFeatures(CreateGatedAPIFeaturesArray(frame->DomWindow()))
.build();
if (loader->Url().HasFragmentIdentifier())
frame_object->setUrlFragment("#" + loader->Url().FragmentIdentifier());
......
Verifies that we can successfully retrieve the security isolation status of a dedicated worker.
{
frameTree : {
frame : {
adFrameType : none
crossOriginIsolatedContextType : Isolated
domainAndRegistry : oopif.test
gatedAPIFeatures : [
[0] : SharedArrayBuffers
[1] : SharedArrayBuffersTransferAllowed
]
id : <string>
loaderId : <string>
mimeType : text/html
secureContextType : Secure
securityOrigin : https://devtools.oopif.test:8443
url : https://devtools.oopif.test:8443/inspector-protocol/network/cross-origin-isolation/resources/page-with-coep-corp.php?coep&corp=same-site&coop
}
resources : [
]
}
}
(async function(testRunner) {
const worker = `console.log("Worker");
onmessage = function(e) {
console.log(e);
};`;
const baseUrl =
`https://devtools.oopif.test:8443/inspector-protocol/network/cross-origin-isolation/resources/page-with-coep-corp.php`;
const url = `${baseUrl}?coep&corp=same-site&coop`;
var {page, session, dp} = await testRunner.startURL(
url,
'Verifies that we can successfully retrieve the security isolation status of a dedicated worker.');
await dp.Page.enable();
const response = await dp.Page.getResourceTree();
testRunner.log(response.result);
testRunner.completeTest();
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment