Commit 02aa8d8c authored by Andrew Comminos's avatar Andrew Comminos Committed by Commit Bot

Add origin trial logic for JS Self-Profiling API

For the initial trial, require site isolation to be present.

Bug: 956688
Change-Id: I18c255118965357f46e46c7aef6ac4cbf4205060
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1707591Reviewed-by: default avatarNicolás Peña Moreno <npm@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Andrew Comminos <acomminos@fb.com>
Cr-Commit-Position: refs/heads/master@{#691456}
parent b016c64b
......@@ -35,11 +35,13 @@
#include "base/metrics/histogram_macros.h"
#include "base/time/default_clock.h"
#include "base/time/default_tick_clock.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/string_or_performance_measure_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_object_builder.h"
#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_exception.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
......@@ -795,6 +797,14 @@ ScriptPromise Performance::profile(ScriptState* script_state,
DCHECK(RuntimeEnabledFeatures::ExperimentalJSProfilerEnabled(
ExecutionContext::From(script_state)));
// The JS Self-Profiling origin trial currently requires site isolation.
if (!Platform::Current()->IsLockedToSite()) {
exception_state.ThrowDOMException(
DOMExceptionCode::kNotSupportedError,
"performance.profile() requires site-per-process (crbug.com/956688)");
return ScriptPromise();
}
auto* profiler_group = ProfilerGroup::From(script_state->GetIsolate());
DCHECK(profiler_group);
......
......@@ -55,13 +55,14 @@ ProfilerGroup::ProfilerGroup(v8::Isolate* isolate)
cpu_profiler_(nullptr),
next_profiler_id_(0),
num_active_profilers_(0) {
DCHECK(RuntimeEnabledFeatures::ExperimentalJSProfilerEnabled());
}
Profiler* ProfilerGroup::CreateProfiler(ScriptState* script_state,
const ProfilerInitOptions& init_options,
base::TimeTicks time_origin,
ExceptionState& exception_state) {
DCHECK(RuntimeEnabledFeatures::ExperimentalJSProfilerEnabled(
ExecutionContext::From(script_state)));
DCHECK_EQ(script_state->GetIsolate(), isolate_);
DCHECK(init_options.hasSampleInterval());
......
......@@ -587,6 +587,7 @@
// https://github.com/WICG/js-self-profiling
{
name: "ExperimentalJSProfiler",
origin_trial_feature_name: "ExperimentalJSProfiler",
status: "experimental"
},
// Enables a set of features intended to help improve web developer
......
<!DOCTYPE html>
<meta charset="utf-8">
<!-- Generate this token with the command:
generate_token.py http://127.0.0.1:8000 ExperimentalJSProfiler --expire-timestamp=2000000000
-- -->
<meta http-equiv="origin-trial" content="AjfjLAG2ob7vRGForWYa9wTsLhhxfIR4iYHWmv4NRkUC/64+gtKIdKbDE/AUb4y4W/RfCMx0ULvFrYQbuDk1CwcAAABeeyJvcmlnaW4iOiAiaHR0cDovLzEyNy4wLjAuMTo4MDAwIiwgImZlYXR1cmUiOiAiRXhwZXJpbWVudGFsSlNQcm9maWxlciIsICJleHBpcnkiOiAyMDAwMDAwMDAwfQ=="/>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/origin-trials-helper.js"></script>
<script>
test(t => {
OriginTrialsHelper.check_properties_exist(this,
{
'Performance': ['profile'],
},
);
}, "JS Self-Profiling API exposed in Origin-Trial enabled document.");
</script>
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