Diff
Modified: trunk/LayoutTests/ChangeLog (222035 => 222036)
--- trunk/LayoutTests/ChangeLog 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/LayoutTests/ChangeLog 2017-09-14 18:09:09 UTC (rev 222036)
@@ -1,3 +1,22 @@
+2017-09-14 Joseph Pecoraro <pecor...@apple.com>
+
+ Web Inspector: Timeline should show when events preventDefault() was called on an event or not
+ https://bugs.webkit.org/show_bug.cgi?id=176824
+ <rdar://problem/34290931>
+
+ Reviewed by Devin Rousso.
+
+ * inspector/timeline/resources/timeline-event-utilities.js: Added.
+ (TestPage.registerInitializer.window.captureTimelineWithScript):
+ (TestPage.registerInitializer):
+ (finishRecording):
+ Helper code for creating a recording from a function.
+
+ * inspector/timeline/timeline-event-EventDispatch-expected.txt: Added.
+ * inspector/timeline/timeline-event-EventDispatch.html: Added.
+ Test for Timeline's EventDispatch records. Ensure it has
+ the new "defaultPrevented" details data.
+
2017-09-14 Matt Lewis <jlew...@apple.com>
Fixed typo in expectations.
Added: trunk/LayoutTests/inspector/timeline/resources/timeline-event-utilities.js (0 => 222036)
--- trunk/LayoutTests/inspector/timeline/resources/timeline-event-utilities.js (rev 0)
+++ trunk/LayoutTests/inspector/timeline/resources/timeline-event-utilities.js 2017-09-14 18:09:09 UTC (rev 222036)
@@ -0,0 +1,23 @@
+TestPage.registerInitializer(() => {
+ window.pageRecordingData = null;
+
+ window.captureTimelineWithScript = function(_expression_) {
+ pageRecordingData = null;
+
+ InspectorTest.log("Starting Capture...");
+ const newRecording = true;
+ WI.timelineManager.startCapturing(newRecording);
+ InspectorTest.evaluateInPage(_expression_);
+ InspectorTest.awaitEvent("FinishRecording").then((event) => {
+ InspectorTest.log("Stopping Capture...");
+ pageRecordingData = event.data;
+ WI.timelineManager.stopCapturing();
+ });
+
+ return WI.timelineManager.awaitEvent(WI.TimelineManager.Event.CapturingStopped);
+ }
+});
+
+function finishRecording(data) {
+ TestPage.dispatchEventToFrontend("FinishRecording", data);
+}
Added: trunk/LayoutTests/inspector/timeline/timeline-event-EventDispatch-expected.txt (0 => 222036)
--- trunk/LayoutTests/inspector/timeline/timeline-event-EventDispatch-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/timeline/timeline-event-EventDispatch-expected.txt 2017-09-14 18:09:09 UTC (rev 222036)
@@ -0,0 +1,37 @@
+Tests 'EventDispatch' Timeline event records.
+
+
+
+== Running test suite: TimelineEvent.EventDispatch
+-- Running test case: TimelineEvent.EventDispatch.Handler.Regular
+Starting Capture...
+click handler fired
+Stopping Capture...
+PASS: Should be 1 EventDispatched record.
+DETAILS: {"type":"click","defaultPrevented":false}
+PASS: ScriptTimelineRecord extraDetails should show default was not prevented.
+
+-- Running test case: TimelineEvent.EventDispatch.Handler.DefaultPrevented
+Starting Capture...
+click handler fired, will prevent default
+Stopping Capture...
+PASS: Should be 1 EventDispatched record.
+DETAILS: {"type":"click","defaultPrevented":true}
+PASS: ScriptTimelineRecord extraDetails should show default was prevented.
+
+-- Running test case: TimelineEvent.EventDispatch.AttributeHandler.Regular
+Starting Capture...
+b1 onclick attribute handler fired
+Stopping Capture...
+PASS: Should be 1 EventDispatched record.
+DETAILS: {"type":"click","defaultPrevented":false}
+PASS: ScriptTimelineRecord extraDetails should show default was not prevented.
+
+-- Running test case: TimelineEvent.EventDispatch.AttributeHandler.DefaultPrevented
+Starting Capture...
+b2 onclick attribute handler fired, will prevent default
+Stopping Capture...
+PASS: Should be 1 EventDispatched record.
+DETAILS: {"type":"click","defaultPrevented":true}
+PASS: ScriptTimelineRecord extraDetails should show default was prevented.
+
Added: trunk/LayoutTests/inspector/timeline/timeline-event-EventDispatch.html (0 => 222036)
--- trunk/LayoutTests/inspector/timeline/timeline-event-EventDispatch.html (rev 0)
+++ trunk/LayoutTests/inspector/timeline/timeline-event-EventDispatch.html 2017-09-14 18:09:09 UTC (rev 222036)
@@ -0,0 +1,110 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+function testClickEventHandler({preventDefault}) {
+ let button = document.body.appendChild(document.createElement("button"));
+ button.addEventListener("click", (event) => {
+ TestPage.addResult("click handler fired" + (preventDefault ? ", will prevent default" : ""));
+ setTimeout(() => { finishRecording({preventDefault}); });
+ if (preventDefault)
+ event.preventDefault();
+ });
+
+ button.dispatchEvent(new MouseEvent("click", {bubbles: true, cancelable: true}));
+}
+
+function testClickEventAttributeHandler(id, {preventDefault}) {
+ let button = document.getElementById(id);
+ button.dispatchEvent(new MouseEvent("click", {bubbles: true, cancelable: true}));
+ setTimeout(() => { finishRecording({preventDefault}); });
+}
+
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("TimelineEvent.EventDispatch");
+
+ suite.addTestCase({
+ name: "TimelineEvent.EventDispatch.Handler.Regular",
+ test(resolve, reject) {
+ captureTimelineWithScript(`testClickEventHandler({preventDefault: false})`).then(() => {
+ InspectorTest.assert(typeof pageRecordingData.preventDefault === "boolean");
+
+ let recording = WI.timelineManager.activeRecording;
+ let scriptTimeline = recording.timelines.get(WI.TimelineRecord.Type.Script);
+ let records = scriptTimeline.records.filter((x) => x.eventType === WI.ScriptTimelineRecord.EventType.EventDispatched);
+ InspectorTest.expectEqual(records.length, 1, "Should be 1 EventDispatched record.");
+ for (let record of records) {
+ InspectorTest.log("DETAILS: " + JSON.stringify(record.extraDetails));
+ InspectorTest.expectEqual(record.extraDetails.defaultPrevented, pageRecordingData.preventDefault, "ScriptTimelineRecord extraDetails should show default was not prevented.");
+ }
+ }).then(resolve, reject);
+ }
+ });
+
+ suite.addTestCase({
+ name: "TimelineEvent.EventDispatch.Handler.DefaultPrevented",
+ test(resolve, reject) {
+ captureTimelineWithScript(`testClickEventHandler({preventDefault: true})`).then(() => {
+ InspectorTest.assert(typeof pageRecordingData.preventDefault === "boolean");
+
+ let recording = WI.timelineManager.activeRecording;
+ let scriptTimeline = recording.timelines.get(WI.TimelineRecord.Type.Script);
+ let records = scriptTimeline.records.filter((x) => x.eventType === WI.ScriptTimelineRecord.EventType.EventDispatched);
+ InspectorTest.expectEqual(records.length, 1, "Should be 1 EventDispatched record.");
+ for (let record of records) {
+ InspectorTest.log("DETAILS: " + JSON.stringify(record.extraDetails));
+ InspectorTest.expectEqual(record.extraDetails.defaultPrevented, pageRecordingData.preventDefault, "ScriptTimelineRecord extraDetails should show default was prevented.");
+ }
+ }).then(resolve, reject);
+ }
+ });
+
+ suite.addTestCase({
+ name: "TimelineEvent.EventDispatch.AttributeHandler.Regular",
+ test(resolve, reject) {
+ captureTimelineWithScript(`testClickEventAttributeHandler("b1", {preventDefault: false})`).then(() => {
+ InspectorTest.assert(typeof pageRecordingData.preventDefault === "boolean");
+
+ let recording = WI.timelineManager.activeRecording;
+ let scriptTimeline = recording.timelines.get(WI.TimelineRecord.Type.Script);
+ let records = scriptTimeline.records.filter((x) => x.eventType === WI.ScriptTimelineRecord.EventType.EventDispatched);
+ InspectorTest.expectEqual(records.length, 1, "Should be 1 EventDispatched record.");
+ for (let record of records) {
+ InspectorTest.log("DETAILS: " + JSON.stringify(record.extraDetails));
+ InspectorTest.expectEqual(record.extraDetails.defaultPrevented, pageRecordingData.preventDefault, "ScriptTimelineRecord extraDetails should show default was not prevented.");
+ }
+ }).then(resolve, reject);
+ }
+ });
+
+ suite.addTestCase({
+ name: "TimelineEvent.EventDispatch.AttributeHandler.DefaultPrevented",
+ test(resolve, reject) {
+ captureTimelineWithScript(`testClickEventAttributeHandler("b2", {preventDefault: true})`).then(() => {
+ InspectorTest.assert(typeof pageRecordingData.preventDefault === "boolean");
+
+ let recording = WI.timelineManager.activeRecording;
+ let scriptTimeline = recording.timelines.get(WI.TimelineRecord.Type.Script);
+ let records = scriptTimeline.records.filter((x) => x.eventType === WI.ScriptTimelineRecord.EventType.EventDispatched);
+ InspectorTest.expectEqual(records.length, 1, "Should be 1 EventDispatched record.");
+ for (let record of records) {
+ InspectorTest.log("DETAILS: " + JSON.stringify(record.extraDetails));
+ InspectorTest.expectEqual(record.extraDetails.defaultPrevented, pageRecordingData.preventDefault, "ScriptTimelineRecord extraDetails should show default was prevented.");
+ }
+ }).then(resolve, reject);
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests 'EventDispatch' Timeline event records.</p>
+<button id="b1" _onclick_="TestPage.addResult('b1 onclick attribute handler fired'); return true"></button>
+<button id="b2" _onclick_="TestPage.addResult('b2 onclick attribute handler fired, will prevent default'); return false"></button>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (222035 => 222036)
--- trunk/Source/WebCore/ChangeLog 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebCore/ChangeLog 2017-09-14 18:09:09 UTC (rev 222036)
@@ -1,3 +1,38 @@
+2017-09-14 Joseph Pecoraro <pecor...@apple.com>
+
+ Web Inspector: Timeline should show when events preventDefault() was called on an event or not
+ https://bugs.webkit.org/show_bug.cgi?id=176824
+ <rdar://problem/34290931>
+
+ Reviewed by Devin Rousso.
+
+ Test: inspector/timeline/timeline-event-EventDispatch.html
+
+ * dom/EventTarget.cpp:
+ (WebCore::EventTarget::fireEventListeners):
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::dispatchEvent):
+ Include defaultPrevented when notifying inspector.
+
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::InspectorInstrumentation::didDispatchEventImpl):
+ (WebCore::InspectorInstrumentation::didDispatchEventOnWindowImpl):
+ * inspector/InspectorInstrumentation.h:
+ (WebCore::InspectorInstrumentation::didDispatchEvent):
+ (WebCore::InspectorInstrumentation::didDispatchEventOnWindow):
+ Pass defaultPrevented on to agent.
+
+ * inspector/InspectorTimelineAgent.cpp:
+ (WebCore::InspectorTimelineAgent::didDispatchEvent):
+ (WebCore::InspectorTimelineAgent::didLayout):
+ (WebCore::InspectorTimelineAgent::didPaint):
+ * inspector/InspectorTimelineAgent.h:
+ * inspector/TimelineRecordFactory.cpp:
+ (WebCore::TimelineRecordFactory::appendLayoutRoot):
+ (WebCore::TimelineRecordFactory::appendDidDispatchEventData):
+ * inspector/TimelineRecordFactory.h:
+ Append a boolean defaultPrevented property on the EventDispatch timeline record's data.
+
2017-09-14 Ryan Haddad <ryanhad...@apple.com>
Unreviewed, rolling out r222015.
Modified: trunk/Source/WebCore/dom/EventTarget.cpp (222035 => 222036)
--- trunk/Source/WebCore/dom/EventTarget.cpp 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebCore/dom/EventTarget.cpp 2017-09-14 18:09:09 UTC (rev 222036)
@@ -299,7 +299,7 @@
}
if (contextIsDocument)
- InspectorInstrumentation::didDispatchEvent(willDispatchEventCookie);
+ InspectorInstrumentation::didDispatchEvent(willDispatchEventCookie, event.defaultPrevented());
}
const EventListenerVector& EventTarget::eventListeners(const AtomicString& eventType)
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (222035 => 222036)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2017-09-14 18:09:09 UTC (rev 222036)
@@ -433,10 +433,10 @@
debuggerAgent->didDispatchAsyncCall();
}
-void InspectorInstrumentation::didDispatchEventImpl(const InspectorInstrumentationCookie& cookie)
+void InspectorInstrumentation::didDispatchEventImpl(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
- timelineAgent->didDispatchEvent();
+ timelineAgent->didDispatchEvent(defaultPrevented);
}
InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindowImpl(InstrumentingAgents& instrumentingAgents, const Event& event, DOMWindow& window)
@@ -451,10 +451,10 @@
return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
}
-void InspectorInstrumentation::didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie& cookie)
+void InspectorInstrumentation::didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
- timelineAgent->didDispatchEvent();
+ timelineAgent->didDispatchEvent(defaultPrevented);
}
InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScriptImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, const String& url, int lineNumber)
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (222035 => 222036)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2017-09-14 18:09:09 UTC (rev 222036)
@@ -147,11 +147,11 @@
static void didAddEventListener(EventTarget&, const AtomicString& eventType);
static void willRemoveEventListener(EventTarget&, const AtomicString& eventType, EventListener&, bool capture);
static InspectorInstrumentationCookie willDispatchEvent(Document&, const Event&, bool hasEventListeners);
- static void didDispatchEvent(const InspectorInstrumentationCookie&);
+ static void didDispatchEvent(const InspectorInstrumentationCookie&, bool defaultPrevented);
static void willHandleEvent(ScriptExecutionContext&, const Event&, const RegisteredEventListener&);
static void didHandleEvent(ScriptExecutionContext&);
static InspectorInstrumentationCookie willDispatchEventOnWindow(Frame*, const Event&, DOMWindow&);
- static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&);
+ static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&, bool defaultPrevented);
static InspectorInstrumentationCookie willEvaluateScript(Frame&, const String& url, int lineNumber);
static void didEvaluateScript(const InspectorInstrumentationCookie&, Frame&);
static InspectorInstrumentationCookie willFireTimer(ScriptExecutionContext&, int timerId);
@@ -321,9 +321,9 @@
static InspectorInstrumentationCookie willDispatchEventImpl(InstrumentingAgents&, Document&, const Event&, bool hasEventListeners);
static void willHandleEventImpl(InstrumentingAgents&, const Event&, const RegisteredEventListener&);
static void didHandleEventImpl(InstrumentingAgents&);
- static void didDispatchEventImpl(const InspectorInstrumentationCookie&);
+ static void didDispatchEventImpl(const InspectorInstrumentationCookie&, bool defaultPrevented);
static InspectorInstrumentationCookie willDispatchEventOnWindowImpl(InstrumentingAgents&, const Event&, DOMWindow&);
- static void didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie&);
+ static void didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie&, bool defaultPrevented);
static InspectorInstrumentationCookie willEvaluateScriptImpl(InstrumentingAgents&, Frame&, const String& url, int lineNumber);
static void didEvaluateScriptImpl(const InspectorInstrumentationCookie&, Frame&);
static InspectorInstrumentationCookie willFireTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext&);
@@ -733,11 +733,11 @@
return InspectorInstrumentationCookie();
}
-inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrumentationCookie& cookie)
+inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
{
FAST_RETURN_IF_NO_FRONTENDS(void());
if (cookie.isValid())
- didDispatchEventImpl(cookie);
+ didDispatchEventImpl(cookie, defaultPrevented);
}
inline void InspectorInstrumentation::willHandleEvent(ScriptExecutionContext& context, const Event& event, const RegisteredEventListener& listener)
@@ -762,11 +762,11 @@
return InspectorInstrumentationCookie();
}
-inline void InspectorInstrumentation::didDispatchEventOnWindow(const InspectorInstrumentationCookie& cookie)
+inline void InspectorInstrumentation::didDispatchEventOnWindow(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
{
FAST_RETURN_IF_NO_FRONTENDS(void());
if (cookie.isValid())
- didDispatchEventOnWindowImpl(cookie);
+ didDispatchEventOnWindowImpl(cookie, defaultPrevented);
}
inline InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScript(Frame& frame, const String& url, int lineNumber)
Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp (222035 => 222036)
--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp 2017-09-14 18:09:09 UTC (rev 222036)
@@ -311,8 +311,12 @@
pushCurrentRecord(TimelineRecordFactory::createEventDispatchData(event), TimelineRecordType::EventDispatch, false, frame);
}
-void InspectorTimelineAgent::didDispatchEvent()
+void InspectorTimelineAgent::didDispatchEvent(bool defaultPrevented)
{
+ TimelineRecordEntry& entry = m_recordStack.last();
+ ASSERT(entry.type == TimelineRecordType::EventDispatch);
+ TimelineRecordFactory::appendDidDispatchEventData(*entry.data.get(), defaultPrevented);
+
didCompleteCurrentRecord(TimelineRecordType::EventDispatch);
}
@@ -335,9 +339,10 @@
Vector<FloatQuad> quads;
root.absoluteQuads(quads);
if (quads.size() >= 1)
- TimelineRecordFactory::appendLayoutRoot(entry.data.get(), quads[0]);
+ TimelineRecordFactory::appendLayoutRoot(*entry.data.get(), quads[0]);
else
ASSERT_NOT_REACHED();
+
didCompleteCurrentRecord(TimelineRecordType::Layout);
}
@@ -382,6 +387,7 @@
FloatQuad quad;
localToPageQuad(renderer, clipRect, &quad);
entry.data = ""
+
didCompleteCurrentRecord(TimelineRecordType::Paint);
}
Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.h (222035 => 222036)
--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.h 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.h 2017-09-14 18:09:09 UTC (rev 222036)
@@ -119,7 +119,7 @@
void willCallFunction(const String& scriptName, int scriptLine, Frame*);
void didCallFunction(Frame*);
void willDispatchEvent(const Event&, Frame*);
- void didDispatchEvent();
+ void didDispatchEvent(bool defaultPrevented);
void willEvaluateScript(const String&, int, Frame&);
void didEvaluateScript(Frame&);
void didInvalidateLayout(Frame&);
Modified: trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp (222035 => 222036)
--- trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp 2017-09-14 18:09:09 UTC (rev 222036)
@@ -146,9 +146,14 @@
return data;
}
-void TimelineRecordFactory::appendLayoutRoot(InspectorObject* data, const FloatQuad& quad)
+void TimelineRecordFactory::appendLayoutRoot(InspectorObject& data, const FloatQuad& quad)
{
- data->setArray(ASCIILiteral("root"), createQuad(quad));
+ data.setArray(ASCIILiteral("root"), createQuad(quad));
}
+void TimelineRecordFactory::appendDidDispatchEventData(InspectorObject& data, bool defaultPrevented)
+{
+ data.setBoolean(ASCIILiteral("defaultPrevented"), defaultPrevented);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/TimelineRecordFactory.h (222035 => 222036)
--- trunk/Source/WebCore/inspector/TimelineRecordFactory.h 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebCore/inspector/TimelineRecordFactory.h 2017-09-14 18:09:09 UTC (rev 222036)
@@ -60,7 +60,8 @@
static Ref<Inspector::InspectorObject> createAnimationFrameData(int callbackId);
static Ref<Inspector::InspectorObject> createPaintData(const FloatQuad&);
- static void appendLayoutRoot(Inspector::InspectorObject* data, const FloatQuad&);
+ static void appendLayoutRoot(Inspector::InspectorObject& data, const FloatQuad&);
+ static void appendDidDispatchEventData(Inspector::InspectorObject& data, bool defaultPrevented);
private:
TimelineRecordFactory() { }
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (222035 => 222036)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2017-09-14 18:09:09 UTC (rev 222036)
@@ -2002,7 +2002,7 @@
bool result = fireEventListeners(event);
- InspectorInstrumentation::didDispatchEventOnWindow(cookie);
+ InspectorInstrumentation::didDispatchEventOnWindow(cookie, event.defaultPrevented());
return result;
}
Modified: trunk/Source/WebInspectorUI/ChangeLog (222035 => 222036)
--- trunk/Source/WebInspectorUI/ChangeLog 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebInspectorUI/ChangeLog 2017-09-14 18:09:09 UTC (rev 222036)
@@ -1,3 +1,41 @@
+2017-09-14 Joseph Pecoraro <pecor...@apple.com>
+
+ Web Inspector: Timeline should show when events preventDefault() was called on an event or not
+ https://bugs.webkit.org/show_bug.cgi?id=176824
+ <rdar://problem/34290931>
+
+ Reviewed by Devin Rousso.
+
+ * Localizations/en.lproj/localizedStrings.js:
+ New string.
+
+ * UserInterface/Controllers/TimelineManager.js:
+ (WI.TimelineManager.prototype._processRecord):
+ Include the whole data object as extra details.
+
+ * UserInterface/Models/ScriptTimelineRecord.js:
+ (WI.ScriptTimelineRecord):
+ (WI.ScriptTimelineRecord.prototype.get extraDetails):
+ Wholesale copy of the extra data instead of just a single property.
+
+ * UserInterface/Views/ScriptDetailsTimelineView.js:
+ (WI.ScriptDetailsTimelineView):
+ Give the name column more initial space, there is still extra space
+ after this adjustment but name is comfortably larger (and the most
+ likely to be expanded).
+
+ * UserInterface/Views/ScriptTimelineDataGridNode.js:
+ (WI.ScriptTimelineDataGridNode.prototype.get subtitle):
+ Include "default prevented" as the event's subtitle if it was prevented.
+
+ * UserInterface/Protocol/InspectorBackend.js:
+ (InspectorBackend.Agent.prototype.dispatchEvent):
+ (InspectorBackend.Agent):
+ * UserInterface/Test.html:
+ * UserInterface/Test/Test.js:
+ (WI.loaded):
+ Add the ScriptProfilerObserver to tests since it is on by default for Timelines.
+
2017-09-14 Ryan Haddad <ryanhad...@apple.com>
Unreviewed, rolling out r222015.
Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (222035 => 222036)
--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2017-09-14 18:09:09 UTC (rev 222036)
@@ -971,6 +971,7 @@
localizedStrings["Zoom:"] = "Zoom:";
localizedStrings["computed"] = "computed";
localizedStrings["default"] = "default";
+localizedStrings["default prevented"] = "default prevented";
localizedStrings["for changes to take effect"] = "for changes to take effect";
localizedStrings["key"] = "key";
localizedStrings["line "] = "line ";
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js (222035 => 222036)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js 2017-09-14 18:09:09 UTC (rev 222036)
@@ -563,7 +563,7 @@
record = new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.TimerFired, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.timerId, profileData);
break;
case TimelineAgent.EventType.EventDispatch:
- record = new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.EventDispatched, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.type, profileData);
+ record = new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.EventDispatched, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.type, profileData, parentRecordPayload.data);
break;
case TimelineAgent.EventType.FireAnimationFrame:
record = new WI.ScriptTimelineRecord(WI.ScriptTimelineRecord.EventType.AnimationFrameFired, startTime, endTime, callFrames, sourceCodeLocation, parentRecordPayload.data.id, profileData);
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js (222035 => 222036)
--- trunk/Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js 2017-09-14 18:09:09 UTC (rev 222036)
@@ -25,7 +25,7 @@
WI.ScriptTimelineRecord = class ScriptTimelineRecord extends WI.TimelineRecord
{
- constructor(eventType, startTime, endTime, callFrames, sourceCodeLocation, details, profilePayload)
+ constructor(eventType, startTime, endTime, callFrames, sourceCodeLocation, details, profilePayload, extraDetails)
{
super(WI.TimelineRecord.Type.Script, startTime, endTime, callFrames, sourceCodeLocation);
@@ -38,6 +38,7 @@
this._details = details || "";
this._profilePayload = profilePayload || null;
this._profile = null;
+ this._extraDetails = extraDetails || null;
// COMPATIBILITY(iOS 9): Before the ScriptProfilerAgent we did not have sample data. Return NaN to match old behavior.
if (!window.ScriptProfilerAgent)
@@ -50,16 +51,11 @@
// Public
- get eventType()
- {
- return this._eventType;
- }
+ get eventType() { return this._eventType; }
+ get details() { return this._details; }
+ get extraDetails() { return this._extraDetails; }
+ get callCountOrSamples() { return this._callCountOrSamples; }
- get details()
- {
- return this._details;
- }
-
get profile()
{
this._initializeProfileFromPayload();
@@ -66,11 +62,6 @@
return this._profile;
}
- get callCountOrSamples()
- {
- return this._callCountOrSamples;
- }
-
isGarbageCollection()
{
return this._eventType === WI.ScriptTimelineRecord.EventType.GarbageCollected;
Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js (222035 => 222036)
--- trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js 2017-09-14 18:09:09 UTC (rev 222036)
@@ -285,6 +285,11 @@
dispatchEvent(eventName, eventArguments)
{
+ if (!this._dispatcher) {
+ console.error("No domain dispatcher registered for domain '" + this._domainName + "'");
+ return false;
+ }
+
if (!(eventName in this._dispatcher)) {
console.error("Protocol Error: Attempted to dispatch an unimplemented method '" + this._domainName + "." + eventName + "'");
return false;
Modified: trunk/Source/WebInspectorUI/UserInterface/Test/Test.js (222035 => 222036)
--- trunk/Source/WebInspectorUI/UserInterface/Test/Test.js 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/Test.js 2017-09-14 18:09:09 UTC (rev 222036)
@@ -38,11 +38,12 @@
InspectorBackend.registerInspectorDispatcher(new WI.InspectorObserver);
InspectorBackend.registerPageDispatcher(new WI.PageObserver);
InspectorBackend.registerConsoleDispatcher(new WI.ConsoleObserver);
+ InspectorBackend.registerNetworkDispatcher(new WI.NetworkObserver);
InspectorBackend.registerDOMDispatcher(new WI.DOMObserver);
- InspectorBackend.registerNetworkDispatcher(new WI.NetworkObserver);
InspectorBackend.registerDebuggerDispatcher(new WI.DebuggerObserver);
InspectorBackend.registerHeapDispatcher(new WI.HeapObserver);
InspectorBackend.registerDOMStorageDispatcher(new WI.DOMStorageObserver);
+ InspectorBackend.registerScriptProfilerDispatcher(new WI.ScriptProfilerObserver);
InspectorBackend.registerTimelineDispatcher(new WI.TimelineObserver);
InspectorBackend.registerCSSDispatcher(new WI.CSSObserver);
InspectorBackend.registerRuntimeDispatcher(new WI.RuntimeObserver);
Modified: trunk/Source/WebInspectorUI/UserInterface/Test.html (222035 => 222036)
--- trunk/Source/WebInspectorUI/UserInterface/Test.html 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebInspectorUI/UserInterface/Test.html 2017-09-14 18:09:09 UTC (rev 222036)
@@ -82,6 +82,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScriptDetailsTimelineView.js (222035 => 222036)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ScriptDetailsTimelineView.js 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScriptDetailsTimelineView.js 2017-09-14 18:09:09 UTC (rev 222036)
@@ -34,7 +34,7 @@
let columns = {name: {}, location: {}, callCount: {}, startTime: {}, totalTime: {}, selfTime: {}, averageTime: {}};
columns.name.title = WI.UIString("Name");
- columns.name.width = "10%";
+ columns.name.width = "30%";
columns.name.icon = true;
columns.name.disclosure = true;
columns.name.locked = true;
@@ -69,7 +69,7 @@
columns.averageTime.width = "10%";
columns.averageTime.aligned = "right";
- for (var column in columns)
+ for (let column in columns)
columns[column].sortable = true;
this._dataGrid = new WI.ScriptTimelineDataGrid(columns);
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js (222035 => 222036)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js 2017-09-14 18:05:55 UTC (rev 222035)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js 2017-09-14 18:09:09 UTC (rev 222036)
@@ -100,6 +100,9 @@
this._subtitle = WI.UIString("%s interval").format(timeoutString);
else
this._subtitle = WI.UIString("%s delay").format(timeoutString);
+ } else if (this._record.eventType === WI.ScriptTimelineRecord.EventType.EventDispatched) {
+ if (this._record.extraDetails && this._record.extraDetails.defaultPrevented)
+ this._subtitle = WI.UIString("default prevented");
}
return this._subtitle;