Diff
Modified: trunk/LayoutTests/ChangeLog (252789 => 252790)
--- trunk/LayoutTests/ChangeLog 2019-11-22 19:55:27 UTC (rev 252789)
+++ trunk/LayoutTests/ChangeLog 2019-11-22 20:01:29 UTC (rev 252790)
@@ -1,3 +1,15 @@
+2019-11-21 Brian Burg <[email protected]>
+
+ Web Inspector: add support for new kinds of diagnostic events
+ https://bugs.webkit.org/show_bug.cgi?id=204430
+
+ Reviewed by Devin Rousso.
+
+ Add new test cases for WI.DiagnosticController.
+
+ * inspector/unit-tests/diagnostic-controller-expected.txt: Added.
+ * inspector/unit-tests/diagnostic-controller.html: Added.
+
2019-11-22 Chris Dumez <[email protected]>
Speculative loading sometimes happens too early and is missing login cookies
Added: trunk/LayoutTests/inspector/unit-tests/diagnostic-controller-expected.txt (0 => 252790)
--- trunk/LayoutTests/inspector/unit-tests/diagnostic-controller-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/unit-tests/diagnostic-controller-expected.txt 2019-11-22 20:01:29 UTC (rev 252790)
@@ -0,0 +1,38 @@
+
+== Running test suite: DiagnosticController
+-- Running test case: DiagnosticController.SetupAndTeardown
+PASS: Diagnostics should not be available initially.
+Adding recorder...
+PASS: Recorder should be inactive prior to diagnostics becoming available.
+Triggering a diagnostic event...
+Making diagnostics available...
+In setup() for recorder: Test.1
+PASS: Recorder should be active after diagnostics are available.
+Triggering a diagnostic event...
+Received diagnostic event: TestEvent.1 => {"answer":"should be logged"}
+Making diagnostics not available...
+In teardown() for recorder: Test.1
+PASS: Recorder should be inactive after diagnostics are not longer available.
+
+-- Running test case: DiagnosticController.AddRecorderWhileActive
+Making diagnostics available...
+Adding recorder...
+In setup() for recorder: Test.2
+Triggering a diagnostic event...
+Received diagnostic event: TestEvent.2 => {"answer":"should be logged"}
+Making diagnostics not available...
+In teardown() for recorder: Test.2
+Triggering a diagnostic event...
+
+-- Running test case: DiagnosticController.AddRecorderWhileInactive
+Making diagnostics not available...
+Adding recorder...
+Triggering a diagnostic event...
+Making diagnostics available...
+In setup() for recorder: Test.3
+Triggering a diagnostic event...
+Received diagnostic event: TestEvent.5 => {"answer":"should be logged"}
+Making diagnostics not available...
+In teardown() for recorder: Test.3
+Triggering a diagnostic event...
+
Added: trunk/LayoutTests/inspector/unit-tests/diagnostic-controller.html (0 => 252790)
--- trunk/LayoutTests/inspector/unit-tests/diagnostic-controller.html (rev 0)
+++ trunk/LayoutTests/inspector/unit-tests/diagnostic-controller.html 2019-11-22 20:01:29 UTC (rev 252790)
@@ -0,0 +1,135 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+ class TestRecorder extends WI.DiagnosticEventRecorder {
+ constructor(name, controller, {setup, teardown} = {}) {
+ super(name, controller);
+
+ this._setupCallback = setup;
+ this._teardownCallback = teardown;
+ }
+
+ setup()
+ {
+ if (typeof this._setupCallback === "function")
+ this._setupCallback(this);
+ }
+
+ teardown()
+ {
+ if (typeof this._teardownCallback === "function")
+ this._teardownCallback(this);
+ }
+
+ sendEvent(name, payload)
+ {
+ this.logDiagnosticEvent(name, payload);
+ }
+ };
+
+ let suite = InspectorTest.createSyncSuite("DiagnosticController");
+
+ suite.addTestCase({
+ name: "DiagnosticController.SetupAndTeardown",
+ test() {
+ let diagnosticController = new WI.DiagnosticController;
+ InspectorTest.expectThat(!diagnosticController.diagnosticLoggingAvailable, "Diagnostics should not be available initially.");
+
+ let recorder = new TestRecorder("Test.1", diagnosticController, {
+ setup: (recorder) => InspectorTest.log("In setup() for recorder: " + recorder.name),
+ teardown: (recorder) => InspectorTest.log("In teardown() for recorder: " + recorder.name),
+ });
+
+ InspectorTest.log("Adding recorder...");
+ diagnosticController.addRecorder(recorder);
+ InspectorTest.expectThat(!recorder.active, "Recorder should be inactive prior to diagnostics becoming available.");
+
+ InspectorTest.log("Triggering a diagnostic event...");
+ recorder.sendEvent("TestEvent.0", {"answer": "should NOT be logged"});
+
+
+ InspectorTest.log("Making diagnostics available...");
+ diagnosticController.diagnosticLoggingAvailable = true;
+ InspectorTest.expectThat(recorder.active, "Recorder should be active after diagnostics are available.");
+
+ InspectorTest.log("Triggering a diagnostic event...");
+ recorder.sendEvent("TestEvent.1", {"answer": "should be logged"});
+
+ InspectorTest.log("Making diagnostics not available...");
+ diagnosticController.diagnosticLoggingAvailable = false;
+
+ InspectorTest.expectThat(!recorder.active, "Recorder should be inactive after diagnostics are not longer available.");
+ }
+ });
+
+ suite.addTestCase({
+ name: "DiagnosticController.AddRecorderWhileActive",
+ test() {
+ let diagnosticController = new WI.DiagnosticController;
+
+ InspectorTest.log("Making diagnostics available...");
+ diagnosticController.diagnosticLoggingAvailable = true;
+
+ let recorder = new TestRecorder("Test.2", diagnosticController, {
+ setup: (recorder) => InspectorTest.log("In setup() for recorder: " + recorder.name),
+ teardown: (recorder) => InspectorTest.log("In teardown() for recorder: " + recorder.name),
+ });
+
+ InspectorTest.log("Adding recorder...");
+ diagnosticController.addRecorder(recorder);
+
+ InspectorTest.log("Triggering a diagnostic event...");
+ recorder.sendEvent("TestEvent.2", {"answer": "should be logged"});
+
+ InspectorTest.log("Making diagnostics not available...");
+ diagnosticController.diagnosticLoggingAvailable = false;
+
+ InspectorTest.log("Triggering a diagnostic event...");
+ recorder.sendEvent("TestEvent.3", {"answer": "should NOT be logged"});
+ }
+ });
+
+ suite.addTestCase({
+ name: "DiagnosticController.AddRecorderWhileInactive",
+ test() {
+ let diagnosticController = new WI.DiagnosticController;
+
+ InspectorTest.log("Making diagnostics not available...");
+ diagnosticController.diagnosticLoggingAvailable = false;
+
+ let recorder = new TestRecorder("Test.3", diagnosticController, {
+ setup: (recorder) => InspectorTest.log("In setup() for recorder: " + recorder.name),
+ teardown: (recorder) => InspectorTest.log("In teardown() for recorder: " + recorder.name),
+ });
+
+ InspectorTest.log("Adding recorder...");
+ diagnosticController.addRecorder(recorder);
+
+ InspectorTest.log("Triggering a diagnostic event...");
+ recorder.sendEvent("TestEvent.4", {"answer": "should NOT be logged"});
+
+ InspectorTest.log("Making diagnostics available...");
+ diagnosticController.diagnosticLoggingAvailable = true;
+
+ InspectorTest.log("Triggering a diagnostic event...");
+ recorder.sendEvent("TestEvent.5", {"answer": "should be logged"});
+
+ InspectorTest.log("Making diagnostics not available...");
+ diagnosticController.diagnosticLoggingAvailable = false;
+
+ InspectorTest.log("Triggering a diagnostic event...");
+ recorder.sendEvent("TestEvent.6", {"answer": "should NOT be logged"});
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onLoad_="runTest()">
+</body>
+</html>
Modified: trunk/Source/WebInspectorUI/ChangeLog (252789 => 252790)
--- trunk/Source/WebInspectorUI/ChangeLog 2019-11-22 19:55:27 UTC (rev 252789)
+++ trunk/Source/WebInspectorUI/ChangeLog 2019-11-22 20:01:29 UTC (rev 252790)
@@ -1,3 +1,88 @@
+2019-11-20 Brian Burg <[email protected]>
+
+ Web Inspector: add support for new kinds of diagnostic events
+ https://bugs.webkit.org/show_bug.cgi?id=204430
+
+ Reviewed by Devin Rousso.
+
+ This patch restructures the existing DiagnosticController to support multiple
+ self-contained event recorders. The first such recorder is for the TabActivity
+ diagnostic event. More will be added later.
+
+ Add two engineering settings: one which auto-logs diagnostic events to Inspector^2 console,
+ and another which forces DiagnosticController to be active or inactive regardless of
+ whether a diagnostic logging delegate is actually installed. This is for manual testing.
+
+ This patch does not introduce any functionality changes to diagnostic event collection.
+ The TabActivityDiagnosticeventRecorder still needs some changes for it to sample correctly.
+
+ New Test: inspector/unit-tests/diagnostic-controller.html
+
+ * UserInterface/Base/Main.js:
+ (WI.contentLoaded):
+
+ * UserInterface/Controllers/DiagnosticController.js:
+ (WI.DiagnosticController):
+ (WI.DiagnosticController.prototype.set diagnosticLoggingAvailable):
+ (WI.DiagnosticController.prototype.addRecorder):
+ (WI.DiagnosticController.prototype.logDiagnosticEvent):
+ (WI.DiagnosticController.prototype._debugEnableDiagnosticLoggingSettingDidChange):
+ (WI.DiagnosticController.prototype._debugAutoLogDiagnosticEventsSettingDidChange):
+ (WI.DiagnosticController.prototype._updateRecorderStates):
+ (WI.DiagnosticController.supportsDiagnosticLogging): Deleted.
+ (WI.DiagnosticController.prototype.logDiagnosticMessage): Deleted.
+ (WI.DiagnosticController.prototype._didInteractWithTabContent): Deleted.
+ (WI.DiagnosticController.prototype._clearTabActivityTimeout): Deleted.
+ (WI.DiagnosticController.prototype._beginTabActivityTimeout): Deleted.
+ (WI.DiagnosticController.prototype._stopTrackingTabActivity): Deleted.
+ (WI.DiagnosticController.prototype._handleWindowFocus): Deleted.
+ (WI.DiagnosticController.prototype._handleWindowBlur): Deleted.
+ (WI.DiagnosticController.prototype._handleWindowKeyDown): Deleted.
+ (WI.DiagnosticController.prototype._handleWindowMouseDown): Deleted.
+ (WI.DiagnosticController.prototype._handleTabBrowserSelectedTabContentViewDidChange): Deleted.
+ Restructure DiagnosticController to be dumber. It holds on to a list of recorders and
+ turns them on and off. All event logging goes through one funnel method, which does not
+ use InspectorFrontendHost at all when running a Web Inspector layout test.
+
+ * UserInterface/Controllers/DiagnosticEventRecorder.js: Added.
+ (WI.DiagnosticEventRecorder):
+ (WI.DiagnosticEventRecorder.prototype.get name):
+ (WI.DiagnosticEventRecorder.prototype.get active):
+ (WI.DiagnosticEventRecorder.prototype.set active):
+ (WI.DiagnosticEventRecorder.prototype.setup):
+ (WI.DiagnosticEventRecorder.prototype.teardown):
+ Add base class for all individual diagnostic event recorders.
+
+ * UserInterface/Controllers/TabActivityDiagnosticEventRecorder.js: Copied from Source/WebInspectorUI/UserInterface/Controllers/DiagnosticController.js.
+ (WI.TabActivityDiagnosticEventRecorder):
+ (WI.TabActivityDiagnosticEventRecorder.prototype.setup):
+ (WI.TabActivityDiagnosticEventRecorder.prototype.teardown):
+ (WI.TabActivityDiagnosticEventRecorder.prototype.handleEvent):
+ (WI.TabActivityDiagnosticEventRecorder.prototype._didInteractWithTabContent):
+ (WI.TabActivityDiagnosticEventRecorder.prototype._clearTabActivityTimeout):
+ (WI.TabActivityDiagnosticEventRecorder.prototype._beginTabActivityTimeout):
+ (WI.TabActivityDiagnosticEventRecorder.prototype._stopTrackingTabActivity):
+ (WI.TabActivityDiagnosticEventRecorder.prototype._handleWindowFocus):
+ (WI.TabActivityDiagnosticEventRecorder.prototype._handleWindowBlur):
+ (WI.TabActivityDiagnosticEventRecorder.prototype._handleWindowKeyDown):
+ (WI.TabActivityDiagnosticEventRecorder.prototype._handleWindowMouseDown):
+ (WI.TabActivityDiagnosticEventRecorder.prototype._handleTabBrowserSelectedTabContentViewDidChange):
+ Move all user activity tracking to here. Restructure so that the recorder can be
+ turned on and off (this adds/removes its listeners and timers).
+
+ * UserInterface/Main.html: Add new files.
+ * UserInterface/Protocol/InspectorFrontendAPI.js:
+ (InspectorFrontendAPI.setDiagnosticLoggingAvailable):
+ Adjust the name, as WI.diagnosticController is no longer underscore-prefixed.
+
+ * UserInterface/Base/Setting.js:
+ Add new settings. Add getter 'valueRespectingDebugUIAvailability' which only
+ returns default values for Debug/Engineering settings if DebugUI is not enabled.
+
+ * UserInterface/Views/SettingsTabContentView.js:
+ (WI.SettingsTabContentView.prototype._createDebugSettingsView):
+ Add new settings to Settings Tab UI.
+
2019-11-21 Nikita Vasilyev <[email protected]>
Web Inspector: Outline sRGB-safe areas on P3 color picker
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (252789 => 252790)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2019-11-22 19:55:27 UTC (rev 252789)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2019-11-22 20:01:29 UTC (rev 252790)
@@ -546,8 +546,10 @@
if (WI.runBootstrapOperations)
WI.runBootstrapOperations();
- if (WI.DiagnosticController.supportsDiagnosticLogging())
- WI._diagnosticController = new WI.DiagnosticController;
+ if (InspectorFrontendHost.supportsDiagnosticLogging) {
+ WI.diagnosticController = new WI.DiagnosticController;
+ WI.diagnosticController.addRecorder(new WI.TabActivityDiagnosticEventRecorder(WI.diagnosticController));
+ }
};
WI.performOneTimeFrontendInitializationsUsingTarget = function(target)
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js (252789 => 252790)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js 2019-11-22 19:55:27 UTC (rev 252789)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js 2019-11-22 20:01:29 UTC (rev 252790)
@@ -116,6 +116,14 @@
this.save();
}
+ get valueRespectingDebugUIAvailability()
+ {
+ if (this._name.startsWith("debug-") || this._name.startsWith("engineering-"))
+ return WI.isDebugUIEnabled() ? this.value : this._defaultValue;
+
+ return this.value;
+ }
+
save()
{
if (!window.InspectorTest && window.localStorage) {
@@ -208,6 +216,8 @@
debugEnableLayoutFlashing: new WI.Setting("debug-enable-layout-flashing", false),
debugEnableStyleEditingDebugMode: new WI.Setting("debug-enable-style-editing-debug-mode", false),
debugEnableUncaughtExceptionReporter: new WI.Setting("debug-enable-uncaught-exception-reporter", true),
+ debugEnableDiagnosticLogging: new WI.Setting("debug-enable-diagnostic-logging", true),
+ debugAutoLogDiagnosticEvents: new WI.Setting("debug-auto-log-diagnostic-events", false),
debugLayoutDirection: new WI.Setting("debug-layout-direction-override", "system"),
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DiagnosticController.js (252789 => 252790)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DiagnosticController.js 2019-11-22 19:55:27 UTC (rev 252789)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DiagnosticController.js 2019-11-22 20:01:29 UTC (rev 252790)
@@ -27,115 +27,69 @@
{
constructor()
{
- this._shouldLogTabContentActivity = true;
- this._tabActivityTimeoutIdentifier = 0;
+ this._diagnosticLoggingAvailable = false;
+ this._recorders = new Set;
- WI.TabBrowser.addEventListener(WI.TabBrowser.Event.SelectedTabContentViewDidChange, this._handleTabBrowserSelectedTabContentViewDidChange, this);
+ this._autoLogDiagnosticEventsToConsole = WI.settings.debugAutoLogDiagnosticEvents.valueRespectingDebugUIAvailability;
+ this._logToConsoleMethod = window.InspectorTest ? InspectorTest.log.bind(InspectorTest) : console.log;
- const options = {
- capture: true,
- };
- window.addEventListener("focus", this._handleWindowFocus.bind(this), options);
- window.addEventListener("blur", this._handleWindowBlur.bind(this), options);
- window.addEventListener("keydown", this._handleWindowKeyDown.bind(this), options);
- window.addEventListener("mousedown", this._handleWindowMouseDown.bind(this), options);
+ WI.settings.debugEnableDiagnosticLogging.addEventListener(WI.Setting.Event.Changed, this._debugEnableDiagnosticLoggingSettingDidChange, this);
+ WI.settings.debugAutoLogDiagnosticEvents.addEventListener(WI.Setting.Event.Changed, this._debugAutoLogDiagnosticEventsSettingDidChange, this);
}
- // Static
-
- static supportsDiagnosticLogging()
- {
- return InspectorFrontendHost.supportsDiagnosticLogging;
- }
-
// Public
- logDiagnosticMessage(eventName, payload)
+ get diagnosticLoggingAvailable()
{
- console.assert(DiagnosticController.supportsDiagnosticLogging());
- console.assert(Object.values(DiagnosticController.EventName).includes(eventName), "Unexpected diagnostic event name " + eventName);
-
- InspectorFrontendHost.logDiagnosticEvent(eventName, JSON.stringify(payload));
+ return this._diagnosticLoggingAvailable;
}
- // Private
-
- _didInteractWithTabContent()
+ set diagnosticLoggingAvailable(available)
{
- if (!this._shouldLogTabContentActivity)
+ if (this._diagnosticLoggingAvailable === available)
return;
- let selectedTabContentView = WI.tabBrowser.selectedTabContentView;
- console.assert(selectedTabContentView);
- if (!selectedTabContentView)
- return;
-
- let tabType = selectedTabContentView.type;
- let interval = DiagnosticController.ActivityTimingResolution;
- this.logDiagnosticMessage(DiagnosticController.EventName.TabActivity, {tabType, interval});
-
- this._beginTabActivityTimeout();
+ this._diagnosticLoggingAvailable = available;
+ this._updateRecorderStates();
}
- _clearTabActivityTimeout()
+ addRecorder(recorder)
{
- if (this._tabActivityTimeoutIdentifier) {
- clearTimeout(this._tabActivityTimeoutIdentifier);
- this._tabActivityTimeoutIdentifier = 0;
- }
+ console.assert(!this._recorders.has(recorder), "Tried to add the same diagnostic recorder more than once.");
+ this._recorders.add(recorder);
+ this._updateRecorderStates();
}
- _beginTabActivityTimeout()
+ logDiagnosticEvent(eventName, payload)
{
- this._stopTrackingTabActivity();
+ // Don't rely on a diagnostic logging delegate to unit test frontend diagnostics code.
+ if (window.InspectorTest) {
+ this._logToConsoleMethod(`Received diagnostic event: ${eventName} => ${JSON.stringify(payload)}`);
+ return;
+ }
- this._tabActivityTimeoutIdentifier = setTimeout(() => {
- this._shouldLogTabContentActivity = true;
- this._tabActivityTimeoutIdentifier = 0;
- }, DiagnosticController.ActivityTimingResolution);
- }
+ if (this._autoLogDiagnosticEventsToConsole)
+ this._logToConsoleMethod(eventName, payload);
- _stopTrackingTabActivity()
- {
- this._clearTabActivityTimeout();
- this._shouldLogTabContentActivity = false;
+ InspectorFrontendHost.logDiagnosticEvent(eventName, JSON.stringify(payload));
}
- _handleWindowFocus(event)
- {
- if (event.target !== window)
- return;
+ // Private
- this._shouldLogTabContentActivity = true;
- }
-
- _handleWindowBlur(event)
+ _debugEnableDiagnosticLoggingSettingDidChange()
{
- if (event.target !== window)
- return;
-
- this._stopTrackingTabActivity();
+ this._updateRecorderStates();
}
- _handleWindowKeyDown(event)
+ _debugAutoLogDiagnosticEventsSettingDidChange()
{
- this._didInteractWithTabContent();
+ this._autoLogDiagnosticEventsToConsole = WI.settings.debugAutoLogDiagnosticEvents.valueRespectingDebugUIAvailability;
}
- _handleWindowMouseDown(event)
+ _updateRecorderStates()
{
- this._didInteractWithTabContent();
+ let isActive = this._diagnosticLoggingAvailable && WI.settings.debugEnableDiagnosticLogging.valueRespectingDebugUIAvailability;
+ for (let recorder of this._recorders)
+ recorder.active = isActive;
}
-
- _handleTabBrowserSelectedTabContentViewDidChange(event)
- {
- this._clearTabActivityTimeout();
- this._shouldLogTabContentActivity = true;
- }
};
-
-WI.DiagnosticController.EventName = {
- TabActivity: "TabActivity",
-};
-
-WI.DiagnosticController.ActivityTimingResolution = 60 * 1000;
Added: trunk/Source/WebInspectorUI/UserInterface/Controllers/DiagnosticEventRecorder.js (0 => 252790)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DiagnosticEventRecorder.js (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DiagnosticEventRecorder.js 2019-11-22 20:01:29 UTC (rev 252790)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WI.DiagnosticEventRecorder = class DiagnosticEventRecorder
+{
+ constructor(name, controller)
+ {
+ console.assert(controller instanceof WI.DiagnosticController, controller);
+
+ this._name = name;
+ this._active = false;
+ this._controller = controller;
+ }
+
+ // Public
+
+ get name() { return this._name; }
+
+ get active()
+ {
+ return this._active;
+ }
+
+ set active(value)
+ {
+ if (this._active === value)
+ return;
+
+ this._active = value;
+
+ if (this._active)
+ this.setup();
+ else
+ this.teardown();
+ }
+
+ // Protected
+
+ logDiagnosticEvent(eventName, payload)
+ {
+ if (this._active)
+ this._controller.logDiagnosticEvent(eventName, payload);
+ }
+
+ setup()
+ {
+ throw WI.NotImplementedError.subclassMustOverride();
+ }
+
+ teardown()
+ {
+ throw WI.NotImplementedError.subclassMustOverride();
+ }
+};
Copied: trunk/Source/WebInspectorUI/UserInterface/Controllers/TabActivityDiagnosticEventRecorder.js (from rev 252789, trunk/Source/WebInspectorUI/UserInterface/Controllers/DiagnosticController.js) (0 => 252790)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/TabActivityDiagnosticEventRecorder.js (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/TabActivityDiagnosticEventRecorder.js 2019-11-22 20:01:29 UTC (rev 252790)
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WI.TabActivityDiagnosticEventRecorder = class TabActivityDiagnosticEventRecorder extends WI.DiagnosticEventRecorder
+{
+ constructor(controller)
+ {
+ super("TabActivity", controller);
+
+ this._shouldLogTabContentActivity = false;
+ this._tabActivityTimeoutIdentifier = 0;
+ }
+
+ // Protected
+
+ setup()
+ {
+ WI.TabBrowser.addEventListener(WI.TabBrowser.Event.SelectedTabContentViewDidChange, this._handleTabBrowserSelectedTabContentViewDidChange, this);
+
+ const options = {
+ capture: true,
+ };
+ window.addEventListener("focus", this, options);
+ window.addEventListener("blur", this, options);
+ window.addEventListener("keydown", this, options);
+ window.addEventListener("mousedown", this, options);
+
+ this._shouldLogTabContentActivity = true;
+ }
+
+ teardown()
+ {
+ WI.TabBrowser.removeEventListener(WI.TabBrowser.Event.SelectedTabContentViewDidChange, this._handleTabBrowserSelectedTabContentViewDidChange, this);
+
+ const options = {
+ capture: true,
+ };
+ window.removeEventListener("focus", this, options);
+ window.removeEventListener("blur", this, options);
+ window.removeEventListener("keydown", this, options);
+ window.removeEventListener("mousedown", this, options);
+
+ this._stopTrackingTabActivity();
+ }
+
+ // Public
+
+ handleEvent(event)
+ {
+ switch (event.type) {
+ case "focus":
+ this._handleWindowFocus(event);
+ break;
+ case "blur":
+ this._handleWindowBlur(event);
+ break;
+ case "keydown":
+ this._handleWindowKeyDown(event);
+ break;
+ case "mousedown":
+ this._handleWindowMouseDown(event);
+ break;
+ }
+ }
+
+ // Private
+
+ _didInteractWithTabContent()
+ {
+ if (!this._shouldLogTabContentActivity)
+ return;
+
+ let selectedTabContentView = WI.tabBrowser.selectedTabContentView;
+ console.assert(selectedTabContentView);
+ if (!selectedTabContentView)
+ return;
+
+ let tabType = selectedTabContentView.type;
+ let interval = TabActivityDiagnosticEventRecorder.ActivityTimingResolution;
+ this.logDiagnosticEvent(this.name, {tabType, interval});
+
+ this._beginTabActivityTimeout();
+ }
+
+ _clearTabActivityTimeout()
+ {
+ if (this._tabActivityTimeoutIdentifier) {
+ clearTimeout(this._tabActivityTimeoutIdentifier);
+ this._tabActivityTimeoutIdentifier = 0;
+ }
+ }
+
+ _beginTabActivityTimeout()
+ {
+ this._stopTrackingTabActivity();
+
+ this._tabActivityTimeoutIdentifier = setTimeout(() => {
+ this._shouldLogTabContentActivity = true;
+ this._tabActivityTimeoutIdentifier = 0;
+ }, TabActivityDiagnosticEventRecorder.ActivityTimingResolution);
+ }
+
+ _stopTrackingTabActivity()
+ {
+ this._clearTabActivityTimeout();
+ this._shouldLogTabContentActivity = false;
+ }
+
+ _handleWindowFocus(event)
+ {
+ if (event.target !== window)
+ return;
+
+ this._shouldLogTabContentActivity = true;
+ }
+
+ _handleWindowBlur(event)
+ {
+ if (event.target !== window)
+ return;
+
+ this._stopTrackingTabActivity();
+ }
+
+ _handleWindowKeyDown(event)
+ {
+ this._didInteractWithTabContent();
+ }
+
+ _handleWindowMouseDown(event)
+ {
+ this._didInteractWithTabContent();
+ }
+
+ _handleTabBrowserSelectedTabContentViewDidChange(event)
+ {
+ this._clearTabActivityTimeout();
+ this._shouldLogTabContentActivity = true;
+ }
+};
+
+WI.TabActivityDiagnosticEventRecorder.ActivityTimingResolution = 60 * 1000;
Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (252789 => 252790)
--- trunk/Source/WebInspectorUI/UserInterface/Main.html 2019-11-22 19:55:27 UTC (rev 252789)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html 2019-11-22 20:01:29 UTC (rev 252790)
@@ -898,6 +898,8 @@
<script src=""
<script src=""
+ <script src=""
+ <script src=""
<script src=""
<script src=""
Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js (252789 => 252790)
--- trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js 2019-11-22 19:55:27 UTC (rev 252789)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js 2019-11-22 20:01:29 UTC (rev 252790)
@@ -77,7 +77,8 @@
setDiagnosticLoggingAvailable: function(available)
{
- // FIXME: update diagnostic availability and start/stop diagnostic recorders.
+ if (WI.diagnosticController)
+ WI.diagnosticController.diagnosticLoggingAvailable = available;
},
showConsole: function()
Modified: trunk/Source/WebInspectorUI/UserInterface/Test.html (252789 => 252790)
--- trunk/Source/WebInspectorUI/UserInterface/Test.html 2019-11-22 19:55:27 UTC (rev 252789)
+++ trunk/Source/WebInspectorUI/UserInterface/Test.html 2019-11-22 20:01:29 UTC (rev 252790)
@@ -268,6 +268,9 @@
<script src=""
<script src=""
+ <script src=""
+ <script src=""
+
<script src=""
<script src=""
<script src=""
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js (252789 => 252790)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js 2019-11-22 19:55:27 UTC (rev 252789)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js 2019-11-22 20:01:29 UTC (rev 252790)
@@ -443,9 +443,11 @@
this._debugSettingsView.addSeparator();
+ let diagnosticsGroup = this._debugSettingsView.addGroup(WI.unlocalizedString("Diagnostics:"));
+ diagnosticsGroup.addSetting(WI.settings.debugEnableUncaughtExceptionReporter, WI.unlocalizedString("Report Uncaught Exceptions"));
+ diagnosticsGroup.addSetting(WI.settings.debugEnableDiagnosticLogging, WI.unlocalizedString("Enable Diagnostic Logging"));
+ diagnosticsGroup.addSetting(WI.settings.debugAutoLogDiagnosticEvents, WI.unlocalizedString("Show Diagnostic Events in Console"));
- this._debugSettingsView.addSetting(WI.unlocalizedString("Uncaught Exception Reporter:"), WI.settings.debugEnableUncaughtExceptionReporter, WI.unlocalizedString("Enabled"));
-
this._debugSettingsView.addSeparator();
const layoutDirectionValues = [