<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[201148] branches/safari-602.1.32-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/201148">201148</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2016-05-19 01:41:03 -0700 (Thu, 19 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/200651">r200651</a>. rdar://problem/26188642</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari602132branchLayoutTestsChangeLog">branches/safari-602.1.32-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari602132branchSourceJavaScriptCoreChangeLog">branches/safari-602.1.32-branch/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchessafari602132branchSourceJavaScriptCoreinspectorprotocolTimelinejson">branches/safari-602.1.32-branch/Source/JavaScriptCore/inspector/protocol/Timeline.json</a></li>
<li><a href="#branchessafari602132branchSourceWebCoreChangeLog">branches/safari-602.1.32-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari602132branchSourceWebCoreinspectorInspectorControllercpp">branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorController.cpp</a></li>
<li><a href="#branchessafari602132branchSourceWebCoreinspectorInspectorInstrumentationcpp">branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorInstrumentation.cpp</a></li>
<li><a href="#branchessafari602132branchSourceWebCoreinspectorInspectorTimelineAgentcpp">branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorTimelineAgent.cpp</a></li>
<li><a href="#branchessafari602132branchSourceWebCoreinspectorInspectorTimelineAgenth">branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorTimelineAgent.h</a></li>
<li><a href="#branchessafari602132branchSourceWebInspectorUIChangeLog">branches/safari-602.1.32-branch/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#branchessafari602132branchSourceWebInspectorUIUserInterfaceControllersTimelineManagerjs">branches/safari-602.1.32-branch/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js</a></li>
<li><a href="#branchessafari602132branchSourceWebInspectorUIUserInterfaceProtocolTimelineObserverjs">branches/safari-602.1.32-branch/Source/WebInspectorUI/UserInterface/Protocol/TimelineObserver.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari602132branchLayoutTestsinspectortimelinesetAutoCaptureInstrumentserrorsexpectedtxt">branches/safari-602.1.32-branch/LayoutTests/inspector/timeline/setAutoCaptureInstruments-errors-expected.txt</a></li>
<li><a href="#branchessafari602132branchLayoutTestsinspectortimelinesetAutoCaptureInstrumentserrorshtml">branches/safari-602.1.32-branch/LayoutTests/inspector/timeline/setAutoCaptureInstruments-errors.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari602132branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/LayoutTests/ChangeLog (201147 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/LayoutTests/ChangeLog        2016-05-19 08:40:55 UTC (rev 201147)
+++ branches/safari-602.1.32-branch/LayoutTests/ChangeLog        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -1,5 +1,20 @@
</span><span class="cx"> 2016-05-19  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r200651. rdar://problem/26188642
+
+    2016-05-10  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+            Web Inspector: Backend should initiate timeline recordings on page navigations to ensure nothing is missed
+            https://bugs.webkit.org/show_bug.cgi?id=157504
+            &lt;rdar://problem/26188642&gt;
+
+            Reviewed by Brian Burg.
+
+            * inspector/timeline/setAutoCaptureInstruments-errors-expected.txt: Added.
+            * inspector/timeline/setAutoCaptureInstruments-errors.html: Added.
+
+2016-05-19  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
</ins><span class="cx">         Merge r201090. rdar://problem/26334636
</span><span class="cx"> 
</span><span class="cx">     2016-05-18  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari602132branchLayoutTestsinspectortimelinesetAutoCaptureInstrumentserrorsexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-602.1.32-branch/LayoutTests/inspector/timeline/setAutoCaptureInstruments-errors-expected.txt (0 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/LayoutTests/inspector/timeline/setAutoCaptureInstruments-errors-expected.txt                                (rev 0)
+++ branches/safari-602.1.32-branch/LayoutTests/inspector/timeline/setAutoCaptureInstruments-errors-expected.txt        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Tests for error cases with Timeline.setAutoCaptureInstruments.
+
+
+== Running test suite: Timeline.setAutoCaptureInstruments.errors
+-- Running test case: MissingRequiredArgument
+PASS: Should be an error: Some arguments of method 'Timeline.setAutoCaptureInstruments' can't be processed
+
+-- Running test case: InvalidTypeInInstrumentsList
+PASS: Should be an error: Unexpected type in instruments list, should be string
+
+-- Running test case: InvalidInstrumentInInstrumentsList
+PASS: Should be an error: Unexpected enum value: NoSuchInstrument
+
+-- Running test case: ValidInstrumentInInstrumentsList
+PASS: Should not be an error setting valid instruments.
+
</ins></span></pre></div>
<a id="branchessafari602132branchLayoutTestsinspectortimelinesetAutoCaptureInstrumentserrorshtml"></a>
<div class="addfile"><h4>Added: branches/safari-602.1.32-branch/LayoutTests/inspector/timeline/setAutoCaptureInstruments-errors.html (0 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/LayoutTests/inspector/timeline/setAutoCaptureInstruments-errors.html                                (rev 0)
+++ branches/safari-602.1.32-branch/LayoutTests/inspector/timeline/setAutoCaptureInstruments-errors.html        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../http/tests/inspector/resources/protocol-test.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+function test()
+{
+    let suite = ProtocolTest.createAsyncSuite(&quot;Timeline.setAutoCaptureInstruments.errors&quot;);
+
+    ProtocolTest.dumpActivityToSystemConsole = true;
+    ProtocolTest.dumpInspectorProtocolMessages = true;
+
+    suite.addTestCase({
+        name: &quot;MissingRequiredArgument&quot;,
+        test: (resolve, reject) =&gt; {
+            InspectorProtocol.sendCommand(&quot;Timeline.setAutoCaptureInstruments&quot;, {}, (messageObject) =&gt; {
+                ProtocolTest.expectThat(messageObject.error, `Should be an error: ${messageObject.error ? messageObject.error.message : &quot;&quot;}`);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;InvalidTypeInInstrumentsList&quot;,
+        test: (resolve, reject) =&gt; {
+            InspectorProtocol.sendCommand(&quot;Timeline.setAutoCaptureInstruments&quot;, {&quot;instruments&quot;: [123]}, (messageObject) =&gt; {
+                ProtocolTest.expectThat(messageObject.error, `Should be an error: ${messageObject.error ? messageObject.error.message : &quot;&quot;}`);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;InvalidInstrumentInInstrumentsList&quot;,
+        test: (resolve, reject) =&gt; {
+            InspectorProtocol.sendCommand(&quot;Timeline.setAutoCaptureInstruments&quot;, {&quot;instruments&quot;: [&quot;NoSuchInstrument&quot;]}, (messageObject) =&gt; {
+                ProtocolTest.expectThat(messageObject.error, `Should be an error: ${messageObject.error ? messageObject.error.message : &quot;&quot;}`);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;ValidInstrumentInInstrumentsList&quot;,
+        test: (resolve, reject) =&gt; {
+            InspectorProtocol.sendCommand(&quot;Timeline.setAutoCaptureInstruments&quot;, {&quot;instruments&quot;: [&quot;ScriptProfiler&quot;, &quot;Heap&quot;, &quot;Timeline&quot;, &quot;Memory&quot;]}, (messageObject) =&gt; {
+                ProtocolTest.expectThat(!messageObject.error, &quot;Should not be an error setting valid instruments.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;p&gt;Tests for error cases with Timeline.setAutoCaptureInstruments.&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari602132branchSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/JavaScriptCore/ChangeLog (201147 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/JavaScriptCore/ChangeLog        2016-05-19 08:40:55 UTC (rev 201147)
+++ branches/safari-602.1.32-branch/Source/JavaScriptCore/ChangeLog        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-05-19  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
+        Merge r200651. rdar://problem/26188642
+
+    2016-05-10  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+            Web Inspector: Backend should initiate timeline recordings on page navigations to ensure nothing is missed
+            https://bugs.webkit.org/show_bug.cgi?id=157504
+            &lt;rdar://problem/26188642&gt;
+
+            Reviewed by Brian Burg.
+
+            * inspector/protocol/Timeline.json:
+            Add protocol commands to enable/disable auto capture and list the
+            instruments that should be enabled when auto capture starts.
+            Add protocol event for when the backend starts an auto capture.
+
</ins><span class="cx"> 2016-05-17  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge r200866. rdar://problem/26253396
</span></span></pre></div>
<a id="branchessafari602132branchSourceJavaScriptCoreinspectorprotocolTimelinejson"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/JavaScriptCore/inspector/protocol/Timeline.json (201147 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/JavaScriptCore/inspector/protocol/Timeline.json        2016-05-19 08:40:55 UTC (rev 201147)
+++ branches/safari-602.1.32-branch/Source/JavaScriptCore/inspector/protocol/Timeline.json        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -6,6 +6,7 @@
</span><span class="cx">         {
</span><span class="cx">             &quot;id&quot;: &quot;EventType&quot;,
</span><span class="cx">             &quot;type&quot;: &quot;string&quot;,
</span><ins>+            &quot;description&quot;: &quot;Timeline record type.&quot;,
</ins><span class="cx">             &quot;enum&quot;: [
</span><span class="cx">                 &quot;EventDispatch&quot;,
</span><span class="cx">                 &quot;ScheduleStyleRecalculation&quot;,
</span><span class="lines">@@ -28,18 +29,28 @@
</span><span class="cx">                 &quot;RequestAnimationFrame&quot;,
</span><span class="cx">                 &quot;CancelAnimationFrame&quot;,
</span><span class="cx">                 &quot;FireAnimationFrame&quot;
</span><del>-            ],
-            &quot;description&quot;: &quot;Timeline record type.&quot;
</del><ins>+            ]
</ins><span class="cx">         },
</span><span class="cx">         {
</span><ins>+            &quot;id&quot;: &quot;Instrument&quot;,
+            &quot;type&quot;: &quot;string&quot;,
+            &quot;description&quot;: &quot;Instrument types.&quot;,
+            &quot;enum&quot;: [
+                &quot;ScriptProfiler&quot;,
+                &quot;Timeline&quot;,
+                &quot;Memory&quot;,
+                &quot;Heap&quot;
+            ]
+        },
+        {
</ins><span class="cx">             &quot;id&quot;: &quot;TimelineEvent&quot;,
</span><span class="cx">             &quot;type&quot;: &quot;object&quot;,
</span><ins>+            &quot;description&quot;: &quot;Timeline record contains information about the recorded activity.&quot;,
</ins><span class="cx">             &quot;properties&quot;: [
</span><span class="cx">                 { &quot;name&quot;: &quot;type&quot;, &quot;$ref&quot;: &quot;EventType&quot;, &quot;description&quot;: &quot;Event type.&quot; },
</span><span class="cx">                 { &quot;name&quot;: &quot;data&quot;, &quot;type&quot;: &quot;object&quot;, &quot;description&quot;: &quot;Event data.&quot; },
</span><span class="cx">                 { &quot;name&quot;: &quot;children&quot;, &quot;type&quot;: &quot;array&quot;, &quot;optional&quot;: true, &quot;items&quot;: { &quot;$ref&quot;: &quot;TimelineEvent&quot; }, &quot;description&quot;: &quot;Nested records.&quot; }
</span><del>-            ],
-            &quot;description&quot;: &quot;Timeline record contains information about the recorded activity.&quot;
</del><ins>+            ]
</ins><span class="cx">         },
</span><span class="cx">         {
</span><span class="cx">             &quot;id&quot;: &quot;CPUProfileNodeAggregateCallInfo&quot;,
</span><span class="lines">@@ -79,37 +90,55 @@
</span><span class="cx">     &quot;commands&quot;: [
</span><span class="cx">         {
</span><span class="cx">             &quot;name&quot;: &quot;start&quot;,
</span><ins>+            &quot;description&quot;: &quot;Starts capturing instrumentation events.&quot;,
</ins><span class="cx">             &quot;parameters&quot;: [
</span><span class="cx">                 { &quot;name&quot;: &quot;maxCallStackDepth&quot;, &quot;optional&quot;: true, &quot;type&quot;: &quot;integer&quot;, &quot;description&quot;: &quot;Samples JavaScript stack traces up to &lt;code&gt;maxCallStackDepth&lt;/code&gt;, defaults to 5.&quot; }
</span><del>-            ],
-            &quot;description&quot;: &quot;Starts capturing instrumentation events.&quot;
</del><ins>+            ]
</ins><span class="cx">         },
</span><span class="cx">         {
</span><span class="cx">             &quot;name&quot;: &quot;stop&quot;,
</span><span class="cx">             &quot;description&quot;: &quot;Stops capturing instrumentation events.&quot;
</span><ins>+        },
+        {
+            &quot;name&quot;: &quot;setAutoCaptureEnabled&quot;,
+            &quot;description&quot;: &quot;Toggle auto capture state. If &lt;code&gt;true&lt;/code&gt; the backend will disable breakpoints and start capturing on navigation. The backend will fire the &lt;code&gt;autoCaptureStarted&lt;/code&gt; event when an auto capture starts. The frontend should stop the auto capture when appropriate and re-enable breakpoints.&quot;,
+            &quot;parameters&quot;: [
+                { &quot;name&quot;: &quot;enabled&quot;, &quot;type&quot;: &quot;boolean&quot;, &quot;description&quot;: &quot;New auto capture state.&quot; }
+            ]
+        },
+        {
+            &quot;name&quot;: &quot;setAutoCaptureInstruments&quot;,
+            &quot;description&quot;: &quot;Instruments to enable when an auto capture starts.&quot;,
+            &quot;parameters&quot;: [
+                { &quot;name&quot;: &quot;instruments&quot;, &quot;type&quot;: &quot;array&quot;, &quot;items&quot;: { &quot;$ref&quot;: &quot;Instrument&quot; }, &quot;description&quot;: &quot;Instruments to enable.&quot; }
+            ]
</ins><span class="cx">         }
</span><span class="cx">     ],
</span><span class="cx">     &quot;events&quot;: [
</span><span class="cx">         {
</span><span class="cx">             &quot;name&quot;: &quot;eventRecorded&quot;,
</span><ins>+            &quot;description&quot;: &quot;Fired for every instrumentation event while timeline is started.&quot;,
</ins><span class="cx">             &quot;parameters&quot;: [
</span><span class="cx">                 { &quot;name&quot;: &quot;record&quot;, &quot;$ref&quot;: &quot;TimelineEvent&quot;, &quot;description&quot;: &quot;Timeline event record data.&quot; }
</span><del>-            ],
-            &quot;description&quot;: &quot;Fired for every instrumentation event while timeline is started.&quot;
</del><ins>+            ]
</ins><span class="cx">         },
</span><span class="cx">         {
</span><span class="cx">             &quot;name&quot;: &quot;recordingStarted&quot;,
</span><ins>+            &quot;description&quot;: &quot;Fired when recording has started.&quot;,
</ins><span class="cx">             &quot;parameters&quot;: [
</span><span class="cx">                 { &quot;name&quot;: &quot;startTime&quot;, &quot;type&quot;: &quot;number&quot;, &quot;description&quot;: &quot;Start time of this new recording.&quot; }
</span><del>-            ],
-            &quot;description&quot;: &quot;Fired when recording has started.&quot;
</del><ins>+            ]
</ins><span class="cx">         },
</span><span class="cx">         {
</span><span class="cx">             &quot;name&quot;: &quot;recordingStopped&quot;,
</span><ins>+            &quot;description&quot;: &quot;Fired when recording has stopped.&quot;,
</ins><span class="cx">             &quot;parameters&quot;: [
</span><span class="cx">                 { &quot;name&quot;: &quot;endTime&quot;, &quot;type&quot;: &quot;number&quot;, &quot;description&quot;: &quot;End time of this recording.&quot; }
</span><del>-            ],
-            &quot;description&quot;: &quot;Fired when recording has stopped.&quot;
</del><ins>+            ]
+        },
+        {
+            &quot;name&quot;: &quot;autoCaptureStarted&quot;,
+            &quot;description&quot;: &quot;Fired when auto capture started.&quot;
</ins><span class="cx">         }
</span><span class="cx">     ]
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebCore/ChangeLog (201147 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebCore/ChangeLog        2016-05-19 08:40:55 UTC (rev 201147)
+++ branches/safari-602.1.32-branch/Source/WebCore/ChangeLog        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -1,5 +1,42 @@
</span><span class="cx"> 2016-05-19  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r200651. rdar://problem/26188642
+
+    2016-05-10  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+            Web Inspector: Backend should initiate timeline recordings on page navigations to ensure nothing is missed
+            https://bugs.webkit.org/show_bug.cgi?id=157504
+            &lt;rdar://problem/26188642&gt;
+
+            Reviewed by Brian Burg.
+
+            Test: inspector/timeline/setAutoCaptureInstruments-errors.html
+
+            * inspector/InspectorController.cpp:
+            (WebCore::InspectorController::InspectorController):
+            Pass other agents into the TimelineAgent constructor.
+
+            * inspector/InspectorInstrumentation.cpp:
+            (WebCore::InspectorInstrumentation::frameStartedLoadingImpl):
+            Inform the TimelineAgent whenever the main frame starts a new load.
+
+            * inspector/InspectorTimelineAgent.h:
+            * inspector/InspectorTimelineAgent.cpp:
+            (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
+            Initialize new members.
+
+            (WebCore::InspectorTimelineAgent::willDestroyFrontendAndBackend):
+            Cleanup auto capture state when tearing down.
+
+            (WebCore::InspectorTimelineAgent::setAutoCaptureEnabled):
+            (WebCore::InspectorTimelineAgent::setAutoCaptureInstruments):
+            Set and validate new auto capture state from the frontend.
+
+            (WebCore::InspectorTimelineAgent::mainFrameStartedLoading):
+            When page navigates start an auto capture if needed.
+
+2016-05-19  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
</ins><span class="cx">         Merge r201090. rdar://problem/26334636
</span><span class="cx"> 
</span><span class="cx">     2016-05-18  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebCoreinspectorInspectorControllercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorController.cpp (201147 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorController.cpp        2016-05-19 08:40:55 UTC (rev 201147)
+++ branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorController.cpp        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -158,25 +158,28 @@
</span><span class="cx">     InspectorDOMStorageAgent* domStorageAgent = domStorageAgentPtr.get();
</span><span class="cx">     m_agents.append(WTFMove(domStorageAgentPtr));
</span><span class="cx"> 
</span><del>-    auto timelineAgentPtr = std::make_unique&lt;InspectorTimelineAgent&gt;(pageContext, pageAgent);
-    m_timelineAgent = timelineAgentPtr.get();
-    m_agents.append(WTFMove(timelineAgentPtr));
-
</del><span class="cx">     auto heapAgentPtr = std::make_unique&lt;InspectorHeapAgent&gt;(pageContext);
</span><span class="cx">     InspectorHeapAgent* heapAgent = heapAgentPtr.get();
</span><span class="cx">     m_agents.append(WTFMove(heapAgentPtr));
</span><span class="cx"> 
</span><ins>+    auto scriptProfilerAgentPtr = std::make_unique&lt;InspectorScriptProfilerAgent&gt;(pageContext);
+    InspectorScriptProfilerAgent* scriptProfilerAgent = scriptProfilerAgentPtr.get();
+    m_agents.append(WTFMove(scriptProfilerAgentPtr));
+
</ins><span class="cx">     auto consoleAgentPtr = std::make_unique&lt;PageConsoleAgent&gt;(pageContext, heapAgent, m_domAgent);
</span><span class="cx">     WebConsoleAgent* consoleAgent = consoleAgentPtr.get();
</span><span class="cx">     m_instrumentingAgents-&gt;setWebConsoleAgent(consoleAgentPtr.get());
</span><span class="cx">     m_agents.append(WTFMove(consoleAgentPtr));
</span><span class="cx"> 
</span><ins>+    auto timelineAgentPtr = std::make_unique&lt;InspectorTimelineAgent&gt;(pageContext, scriptProfilerAgent, heapAgent, pageAgent);
+    m_timelineAgent = timelineAgentPtr.get();
+    m_agents.append(WTFMove(timelineAgentPtr));
+
</ins><span class="cx">     auto debuggerAgentPtr = std::make_unique&lt;PageDebuggerAgent&gt;(pageContext, pageAgent, m_overlay.get());
</span><span class="cx">     PageDebuggerAgent* debuggerAgent = debuggerAgentPtr.get();
</span><span class="cx">     m_agents.append(WTFMove(debuggerAgentPtr));
</span><span class="cx"> 
</span><span class="cx">     m_agents.append(std::make_unique&lt;InspectorDOMDebuggerAgent&gt;(pageContext, m_domAgent, debuggerAgent));
</span><del>-    m_agents.append(std::make_unique&lt;InspectorScriptProfilerAgent&gt;(pageContext));
</del><span class="cx">     m_agents.append(std::make_unique&lt;InspectorApplicationCacheAgent&gt;(pageContext, pageAgent));
</span><span class="cx">     m_agents.append(std::make_unique&lt;InspectorLayerTreeAgent&gt;(pageContext));
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebCoreinspectorInspectorInstrumentationcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorInstrumentation.cpp (201147 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorInstrumentation.cpp        2016-05-19 08:40:55 UTC (rev 201147)
+++ branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorInstrumentation.cpp        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -775,6 +775,8 @@
</span><span class="cx">     if (frame.isMainFrame()) {
</span><span class="cx">         if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
</span><span class="cx">             pageDebuggerAgent-&gt;mainFrameStartedLoading();
</span><ins>+        if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.persistentInspectorTimelineAgent())
+            timelineAgent-&gt;mainFrameStartedLoading();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents.inspectorPageAgent())
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebCoreinspectorInspectorTimelineAgentcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorTimelineAgent.cpp (201147 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorTimelineAgent.cpp        2016-05-19 08:40:55 UTC (rev 201147)
+++ branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorTimelineAgent.cpp        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Event.h&quot;
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><ins>+#include &quot;InspectorMemoryAgent.h&quot;
</ins><span class="cx"> #include &quot;InspectorPageAgent.h&quot;
</span><span class="cx"> #include &quot;InstrumentingAgents.h&quot;
</span><span class="cx"> #include &quot;JSDOMWindow.h&quot;
</span><span class="lines">@@ -43,6 +44,9 @@
</span><span class="cx"> #include &quot;ScriptState.h&quot;
</span><span class="cx"> #include &quot;TimelineRecordFactory.h&quot;
</span><span class="cx"> #include &lt;inspector/ScriptBreakpoint.h&gt;
</span><ins>+#include &lt;inspector/agents/InspectorDebuggerAgent.h&gt;
+#include &lt;inspector/agents/InspectorHeapAgent.h&gt;
+#include &lt;inspector/agents/InspectorScriptProfilerAgent.h&gt;
</ins><span class="cx"> #include &lt;profiler/LegacyProfiler.h&gt;
</span><span class="cx"> #include &lt;wtf/Stopwatch.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -77,6 +81,16 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+InspectorTimelineAgent::InspectorTimelineAgent(WebAgentContext&amp; context, InspectorScriptProfilerAgent* scriptProfileAgent, InspectorHeapAgent* heapAgent, InspectorPageAgent* pageAgent)
+    : InspectorAgentBase(ASCIILiteral(&quot;Timeline&quot;), context)
+    , m_frontendDispatcher(std::make_unique&lt;Inspector::TimelineFrontendDispatcher&gt;(context.frontendRouter))
+    , m_backendDispatcher(Inspector::TimelineBackendDispatcher::create(context.backendDispatcher, this))
+    , m_scriptProfilerAgent(scriptProfileAgent)
+    , m_heapAgent(heapAgent)
+    , m_pageAgent(pageAgent)
+{
+}
+
</ins><span class="cx"> InspectorTimelineAgent::~InspectorTimelineAgent()
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -92,6 +106,9 @@
</span><span class="cx"> 
</span><span class="cx">     ErrorString unused;
</span><span class="cx">     stop(unused);
</span><ins>+
+    m_autoCaptureEnabled = false;
+    m_autoCaptureInstruments.clear();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InspectorTimelineAgent::start(ErrorString&amp;, const int* maxCallStackDepth)
</span><span class="lines">@@ -108,6 +125,35 @@
</span><span class="cx">     m_enabledFromFrontend = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void InspectorTimelineAgent::setAutoCaptureEnabled(ErrorString&amp;, bool enabled)
+{
+    m_autoCaptureEnabled = enabled;
+}
+
+void InspectorTimelineAgent::setAutoCaptureInstruments(ErrorString&amp; errorString, const InspectorArray&amp; instruments)
+{
+    Vector&lt;Protocol::Timeline::Instrument&gt; newInstruments;
+    newInstruments.reserveCapacity(instruments.length());
+
+    for (auto instrumentValue : instruments) {
+        String enumValueString;
+        if (!instrumentValue-&gt;asString(enumValueString)) {
+            errorString = ASCIILiteral(&quot;Unexpected type in instruments list, should be string&quot;);
+            return;
+        }
+
+        Optional&lt;Protocol::Timeline::Instrument&gt; instrumentType = Protocol::InspectorHelpers::parseEnumValueFromString&lt;Protocol::Timeline::Instrument&gt;(enumValueString);
+        if (!instrumentType) {
+            errorString = makeString(&quot;Unexpected enum value: &quot;, enumValueString);
+            return;
+        }
+
+        newInstruments.uncheckedAppend(*instrumentType);
+    }
+
+    m_autoCaptureInstruments.swap(newInstruments);
+}
+
</ins><span class="cx"> void InspectorTimelineAgent::internalStart(const int* maxCallStackDepth)
</span><span class="cx"> {
</span><span class="cx">     if (m_enabled)
</span><span class="lines">@@ -384,6 +430,60 @@
</span><span class="cx">     appendRecord(TimelineRecordFactory::createTimeStampData(message), TimelineRecordType::TimeEnd, true, &amp;frame);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void InspectorTimelineAgent::mainFrameStartedLoading()
+{
+    if (m_enabled)
+        return;
+
+    if (!m_autoCaptureEnabled)
+        return;
+
+    if (m_autoCaptureInstruments.isEmpty())
+        return;
+
+    // Pre-emptively disable breakpoints. The frontend must re-enable them.
+    if (InspectorDebuggerAgent* debuggerAgent = m_instrumentingAgents.inspectorDebuggerAgent()) {
+        ErrorString unused;
+        debuggerAgent-&gt;setBreakpointsActive(unused, false);
+    }
+
+    // Inform the frontend we started an auto capture. The frontend must stop capture.
+    m_frontendDispatcher-&gt;autoCaptureStarted();
+
+    // Enable instruments.
+    for (auto instrumentType : m_autoCaptureInstruments) {
+        switch (instrumentType) {
+        case Inspector::Protocol::Timeline::Instrument::ScriptProfiler: {
+            if (m_scriptProfilerAgent) {
+                ErrorString unused;
+                const bool includeSamples = true;
+                m_scriptProfilerAgent-&gt;startTracking(unused, &amp;includeSamples);
+            }
+            break;
+        }
+        case Inspector::Protocol::Timeline::Instrument::Heap: {
+            if (m_heapAgent) {
+                ErrorString unused;
+                m_heapAgent-&gt;startTracking(unused);
+            }
+            break;
+        }
+        case Inspector::Protocol::Timeline::Instrument::Memory: {
+#if ENABLE(RESOURCE_USAGE)
+            if (InspectorMemoryAgent* memoryAgent = m_instrumentingAgents.inspectorMemoryAgent()) {
+                ErrorString unused;
+                memoryAgent-&gt;startTracking(unused);
+            }
+#endif
+            break;
+        }
+        case Inspector::Protocol::Timeline::Instrument::Timeline:
+            internalStart();
+            break;
+        }
+    }
+}
+
</ins><span class="cx"> void InspectorTimelineAgent::didCommitLoad()
</span><span class="cx"> {
</span><span class="cx">     clearRecordStack();
</span><span class="lines">@@ -524,14 +624,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-InspectorTimelineAgent::InspectorTimelineAgent(WebAgentContext&amp; context, InspectorPageAgent* pageAgent)
-    : InspectorAgentBase(ASCIILiteral(&quot;Timeline&quot;), context)
-    , m_frontendDispatcher(std::make_unique&lt;Inspector::TimelineFrontendDispatcher&gt;(context.frontendRouter))
-    , m_backendDispatcher(Inspector::TimelineBackendDispatcher::create(context.backendDispatcher, this))
-    , m_pageAgent(pageAgent)
-{
-}
-
</del><span class="cx"> void InspectorTimelineAgent::appendRecord(RefPtr&lt;InspectorObject&gt;&amp;&amp; data, TimelineRecordType type, bool captureCallStack, Frame* frame)
</span><span class="cx"> {
</span><span class="cx">     Ref&lt;InspectorObject&gt; record = TimelineRecordFactory::createGenericRecord(timestamp(), captureCallStack ? m_maxCallStackDepth : 0);
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebCoreinspectorInspectorTimelineAgenth"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorTimelineAgent.h (201147 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorTimelineAgent.h        2016-05-19 08:40:55 UTC (rev 201147)
+++ branches/safari-602.1.32-branch/Source/WebCore/inspector/InspectorTimelineAgent.h        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -45,6 +45,11 @@
</span><span class="cx"> class Profile;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+namespace Inspector {
+class InspectorHeapAgent;
+class InspectorScriptProfilerAgent;
+}
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class Event;
</span><span class="lines">@@ -92,7 +97,7 @@
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(InspectorTimelineAgent);
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    InspectorTimelineAgent(WebAgentContext&amp;, InspectorPageAgent*);
</del><ins>+    InspectorTimelineAgent(WebAgentContext&amp;, Inspector::InspectorScriptProfilerAgent*, Inspector::InspectorHeapAgent*, InspectorPageAgent*);
</ins><span class="cx">     virtual ~InspectorTimelineAgent();
</span><span class="cx"> 
</span><span class="cx">     void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) final;
</span><span class="lines">@@ -100,6 +105,8 @@
</span><span class="cx"> 
</span><span class="cx">     void start(ErrorString&amp;, const int* maxCallStackDepth = nullptr) final;
</span><span class="cx">     void stop(ErrorString&amp;) final;
</span><ins>+    void setAutoCaptureEnabled(ErrorString&amp;, bool) final;
+    void setAutoCaptureInstruments(ErrorString&amp;, const Inspector::InspectorArray&amp;) final;
</ins><span class="cx"> 
</span><span class="cx">     int id() const { return m_id; }
</span><span class="cx"> 
</span><span class="lines">@@ -137,6 +144,7 @@
</span><span class="cx">     void didFireAnimationFrame();
</span><span class="cx">     void time(Frame&amp;, const String&amp;);
</span><span class="cx">     void timeEnd(Frame&amp;, const String&amp;);
</span><ins>+    void mainFrameStartedLoading();
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     // ScriptDebugListener
</span><span class="lines">@@ -191,6 +199,8 @@
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;Inspector::TimelineFrontendDispatcher&gt; m_frontendDispatcher;
</span><span class="cx">     RefPtr&lt;Inspector::TimelineBackendDispatcher&gt; m_backendDispatcher;
</span><ins>+    Inspector::InspectorScriptProfilerAgent* m_scriptProfilerAgent;
+    Inspector::InspectorHeapAgent* m_heapAgent;
</ins><span class="cx">     InspectorPageAgent* m_pageAgent;
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;TimelineRecordEntry&gt; m_recordStack;
</span><span class="lines">@@ -202,6 +212,9 @@
</span><span class="cx">     bool m_enabled { false };
</span><span class="cx">     bool m_enabledFromFrontend { false };
</span><span class="cx"> 
</span><ins>+    bool m_autoCaptureEnabled { false };
+    Vector&lt;Inspector::Protocol::Timeline::Instrument&gt; m_autoCaptureInstruments;
+
</ins><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     std::unique_ptr&lt;WebCore::RunLoopObserver&gt; m_frameStartObserver;
</span><span class="cx">     std::unique_ptr&lt;WebCore::RunLoopObserver&gt; m_frameStopObserver;
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebInspectorUI/ChangeLog (201147 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebInspectorUI/ChangeLog        2016-05-19 08:40:55 UTC (rev 201147)
+++ branches/safari-602.1.32-branch/Source/WebInspectorUI/ChangeLog        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -1,5 +1,47 @@
</span><span class="cx"> 2016-05-19  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r200651. rdar://problem/26188642
+
+    2016-05-10  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+            Web Inspector: Backend should initiate timeline recordings on page navigations to ensure nothing is missed
+            https://bugs.webkit.org/show_bug.cgi?id=157504
+            &lt;rdar://problem/26188642&gt;
+
+            Reviewed by Brian Burg.
+
+            * UserInterface/Controllers/TimelineManager.js:
+            (WebInspector.TimelineManager):
+            (WebInspector.TimelineManager.prototype.set autoCaptureOnPageLoad):
+            (WebInspector.TimelineManager.prototype.set enabledTimelineTypes):
+            (WebInspector.TimelineManager.prototype._updateAutoCaptureInstruments):
+            For backends that support it, enable/disable auto capture and the instruments to use.
+
+            (WebInspector.TimelineManager.prototype.autoCaptureStarted):
+            New event, stop and start a new recording. Set a flag that we should
+            detect the auto capturing resource so we know when the stop the
+            auto capture.
+
+            (WebInspector.TimelineManager.prototype._loadNewRecording):
+            (WebInspector.TimelineManager.prototype._addRecord):
+            (WebInspector.TimelineManager.prototype._startAutoCapturing): Renamed.
+            (WebInspector.TimelineManager.prototype._attemptAutoCapturingForFrame):
+            (WebInspector.TimelineManager.prototype._legacyAttemptStartAutoCapturingForFrame):
+            (WebInspector.TimelineManager.prototype._stopAutoRecordingSoon):
+            (WebInspector.TimelineManager.prototype._resetAutoRecordingMaxTimeTimeout):
+            (WebInspector.TimelineManager.prototype._resetAutoRecordingDeadTimeTimeout):
+            (WebInspector.TimelineManager.prototype._mainResourceDidChange):
+            (WebInspector.TimelineManager.prototype._mergeScriptProfileRecords):
+            Factor out the new path, old path, and shared code for auto capturing.
+            Renamed _startAutoCapturing to _attemptAutoCapturingForFrame which
+            better matches what it tries to do.
+
+            * UserInterface/Protocol/TimelineObserver.js:
+            (WebInspector.TimelineObserver.prototype.autoCaptureStarted):
+            Inform TimelineManager.
+
+2016-05-19  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
</ins><span class="cx">         Merge r200949. rdar://problem/26262219
</span><span class="cx"> 
</span><span class="cx">     2016-05-14  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebInspectorUIUserInterfaceControllersTimelineManagerjs"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js (201147 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js        2016-05-19 08:40:55 UTC (rev 201147)
+++ branches/safari-602.1.32-branch/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx">     {
</span><span class="cx">         super();
</span><span class="cx"> 
</span><del>-        WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ProvisionalLoadStarted, this._startAutoCapturing, this);
</del><ins>+        WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ProvisionalLoadStarted, this._provisionalLoadStarted, this);
</ins><span class="cx">         WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
</span><span class="cx">         WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ResourceWasAdded, this._resourceWasAdded, this);
</span><span class="cx"> 
</span><span class="lines">@@ -37,12 +37,15 @@
</span><span class="cx">         WebInspector.memoryManager.addEventListener(WebInspector.MemoryManager.Event.MemoryPressure, this._memoryPressure, this);
</span><span class="cx"> 
</span><span class="cx">         this._enabledTimelineTypesSetting = new WebInspector.Setting(&quot;enabled-instrument-types&quot;, WebInspector.TimelineManager.defaultTimelineTypes());
</span><ins>+        this._updateAutoCaptureInstruments();
</ins><span class="cx"> 
</span><span class="cx">         this._persistentNetworkTimeline = new WebInspector.NetworkTimeline;
</span><span class="cx"> 
</span><span class="cx">         this._isCapturing = false;
</span><span class="cx">         this._isCapturingPageReload = false;
</span><del>-        this._autoCapturingMainResource = null;
</del><ins>+        this._autoCaptureOnPageLoad = false;
+        this._mainResourceForAutoCapturing = null;
+        this._shouldSetAutoCapturingMainResource = false;
</ins><span class="cx">         this._boundStopCapturing = this.stopCapturing.bind(this);
</span><span class="cx"> 
</span><span class="cx">         this._webTimelineScriptRecordsExpectingScriptProfilerEvents = null;
</span><span class="lines">@@ -128,6 +131,9 @@
</span><span class="cx">     set autoCaptureOnPageLoad(autoCapture)
</span><span class="cx">     {
</span><span class="cx">         this._autoCaptureOnPageLoad = autoCapture;
</span><ins>+
+        if (window.TimelineAgent &amp;&amp; TimelineAgent.setAutoCaptureEnabled)
+            TimelineAgent.setAutoCaptureEnabled(autoCapture);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     get enabledTimelineTypes()
</span><span class="lines">@@ -139,6 +145,8 @@
</span><span class="cx">     set enabledTimelineTypes(x)
</span><span class="cx">     {
</span><span class="cx">         this._enabledTimelineTypesSetting.value = x || [];
</span><ins>+
+        this._updateAutoCaptureInstruments();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     isCapturing()
</span><span class="lines">@@ -204,6 +212,8 @@
</span><span class="cx"> 
</span><span class="cx">     capturingStarted(startTime)
</span><span class="cx">     {
</span><ins>+        // Called from WebInspector.TimelineObserver.
+
</ins><span class="cx">         if (this._isCapturing)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="lines">@@ -219,6 +229,8 @@
</span><span class="cx"> 
</span><span class="cx">     capturingStopped(endTime)
</span><span class="cx">     {
</span><ins>+        // Called from WebInspector.TimelineObserver.
+
</ins><span class="cx">         if (!this._isCapturing)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="lines">@@ -234,11 +246,24 @@
</span><span class="cx"> 
</span><span class="cx">         this._isCapturing = false;
</span><span class="cx">         this._isCapturingPageReload = false;
</span><del>-        this._autoCapturingMainResource = null;
</del><ins>+        this._shouldSetAutoCapturingMainResource = false;
+        this._mainResourceForAutoCapturing = null;
</ins><span class="cx"> 
</span><span class="cx">         this.dispatchEventToListeners(WebInspector.TimelineManager.Event.CapturingStopped, {endTime});
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    autoCaptureStarted(startTime)
+    {
+        // Called from WebInspector.TimelineObserver.
+
+        if (this._isCapturing)
+            this.stopCapturing();
+
+        this.startCapturing(true);
+
+        this._shouldSetAutoCapturingMainResource = true;
+    }
+
</ins><span class="cx">     eventRecorded(recordPayload)
</span><span class="cx">     {
</span><span class="cx">         // Called from WebInspector.TimelineObserver.
</span><span class="lines">@@ -591,10 +616,10 @@
</span><span class="cx">         // Now that we have navigated, we should reset the legacy base timestamp and the
</span><span class="cx">         // will send request timestamp for the new main resource. This way, all new timeline
</span><span class="cx">         // records will be computed relative to the new navigation.
</span><del>-        if (this._autoCapturingMainResource &amp;&amp; WebInspector.TimelineRecording.isLegacy) {
-            console.assert(this._autoCapturingMainResource.originalRequestWillBeSentTimestamp);
-            this._activeRecording.setLegacyBaseTimestamp(this._autoCapturingMainResource.originalRequestWillBeSentTimestamp);
-            this._autoCapturingMainResource._requestSentTimestamp = 0;
</del><ins>+        if (this._mainResourceForAutoCapturing &amp;&amp; WebInspector.TimelineRecording.isLegacy) {
+            console.assert(this._mainResourceForAutoCapturing.originalRequestWillBeSentTimestamp);
+            this._activeRecording.setLegacyBaseTimestamp(this._mainResourceForAutoCapturing.originalRequestWillBeSentTimestamp);
+            this._mainResourceForAutoCapturing._requestSentTimestamp = 0;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         this.dispatchEventToListeners(WebInspector.TimelineManager.Event.RecordingLoaded, {oldRecording});
</span><span class="lines">@@ -617,25 +642,58 @@
</span><span class="cx">             this._resetAutoRecordingDeadTimeTimeout();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    _startAutoCapturing(event)
</del><ins>+    _attemptAutoCapturingForFrame(frame)
</ins><span class="cx">     {
</span><span class="cx">         if (!this._autoCaptureOnPageLoad)
</span><span class="cx">             return false;
</span><span class="cx"> 
</span><del>-        if (!event.target.isMainFrame() || (this._isCapturing &amp;&amp; !this._autoCapturingMainResource))
</del><ins>+        if (!frame.isMainFrame())
</ins><span class="cx">             return false;
</span><span class="cx"> 
</span><del>-        var mainResource = event.target.provisionalMainResource || event.target.mainResource;
-        if (mainResource === this._autoCapturingMainResource)
</del><ins>+        // COMPATIBILITY (iOS 9): Timeline.setAutoCaptureEnabled did not exist.
+        // Perform auto capture in the frontend.
+        if (!TimelineAgent.setAutoCaptureEnabled)
+            return this._legacyAttemptStartAutoCapturingForFrame(frame);
+
+        if (!this._shouldSetAutoCapturingMainResource)
</ins><span class="cx">             return false;
</span><span class="cx"> 
</span><del>-        var oldMainResource = event.target.mainResource || null;
</del><ins>+        console.assert(this._isCapturing, &quot;We saw autoCaptureStarted so we should already be capturing&quot;);
+
+        let mainResource = frame.provisionalMainResource || frame.mainResource;
+        if (mainResource === this._mainResourceForAutoCapturing)
+            return false;
+
+        let oldMainResource = frame.mainResource || null;
</ins><span class="cx">         this._isCapturingPageReload = oldMainResource !== null &amp;&amp; oldMainResource.url === mainResource.url;
</span><span class="cx"> 
</span><ins>+        this._mainResourceForAutoCapturing = mainResource;
+
+        this._addRecord(new WebInspector.ResourceTimelineRecord(mainResource));
+
+        this._resetAutoRecordingMaxTimeTimeout();
+
+        this._shouldSetAutoCapturingMainResource = false;
+
+        return true;
+    }
+
+    _legacyAttemptStartAutoCapturingForFrame(frame)
+    {
+        if (this._isCapturing &amp;&amp; !this._mainResourceForAutoCapturing)
+            return false;
+
+        let mainResource = frame.provisionalMainResource || frame.mainResource;
+        if (mainResource === this._mainResourceForAutoCapturing)
+            return false;
+
+        let oldMainResource = frame.mainResource || null;
+        this._isCapturingPageReload = oldMainResource !== null &amp;&amp; oldMainResource.url === mainResource.url;
+
</ins><span class="cx">         if (this._isCapturing)
</span><span class="cx">             this.stopCapturing();
</span><span class="cx"> 
</span><del>-        this._autoCapturingMainResource = mainResource;
</del><ins>+        this._mainResourceForAutoCapturing = mainResource;
</ins><span class="cx"> 
</span><span class="cx">         this._loadNewRecording();
</span><span class="cx"> 
</span><span class="lines">@@ -643,9 +701,7 @@
</span><span class="cx"> 
</span><span class="cx">         this._addRecord(new WebInspector.ResourceTimelineRecord(mainResource));
</span><span class="cx"> 
</span><del>-        if (this._stopCapturingTimeout)
-            clearTimeout(this._stopCapturingTimeout);
-        this._stopCapturingTimeout = setTimeout(this._boundStopCapturing, WebInspector.TimelineManager.MaximumAutoRecordDuration);
</del><ins>+        this._resetAutoRecordingMaxTimeTimeout();
</ins><span class="cx"> 
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="lines">@@ -653,7 +709,7 @@
</span><span class="cx">     _stopAutoRecordingSoon()
</span><span class="cx">     {
</span><span class="cx">         // Only auto stop when auto capturing.
</span><del>-        if (!this._isCapturing || !this._autoCapturingMainResource)
</del><ins>+        if (!this._isCapturing || !this._mainResourceForAutoCapturing)
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         if (this._stopCapturingTimeout)
</span><span class="lines">@@ -661,10 +717,17 @@
</span><span class="cx">         this._stopCapturingTimeout = setTimeout(this._boundStopCapturing, WebInspector.TimelineManager.MaximumAutoRecordDurationAfterLoadEvent);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    _resetAutoRecordingMaxTimeTimeout()
+    {
+        if (this._stopCapturingTimeout)
+            clearTimeout(this._stopCapturingTimeout);
+        this._stopCapturingTimeout = setTimeout(this._boundStopCapturing, WebInspector.TimelineManager.MaximumAutoRecordDuration);
+    }
+
</ins><span class="cx">     _resetAutoRecordingDeadTimeTimeout()
</span><span class="cx">     {
</span><span class="cx">         // Only monitor dead time when auto capturing.
</span><del>-        if (!this._isCapturing || !this._autoCapturingMainResource)
</del><ins>+        if (!this._isCapturing || !this._mainResourceForAutoCapturing)
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         if (this._deadTimeTimeout)
</span><span class="lines">@@ -672,13 +735,19 @@
</span><span class="cx">         this._deadTimeTimeout = setTimeout(this._boundStopCapturing, WebInspector.TimelineManager.DeadTimeRequiredToStopAutoRecordingEarly);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    _provisionalLoadStarted(event)
+    {
+        this._attemptAutoCapturingForFrame(event.target);
+    }
+
</ins><span class="cx">     _mainResourceDidChange(event)
</span><span class="cx">     {
</span><del>-        if (event.target.isMainFrame())
</del><ins>+        let frame = event.target;
+        if (frame.isMainFrame())
</ins><span class="cx">             this._persistentNetworkTimeline.reset();
</span><span class="cx"> 
</span><del>-        var mainResource = event.target.mainResource;
-        var record = new WebInspector.ResourceTimelineRecord(mainResource);
</del><ins>+        let mainResource = frame.mainResource;
+        let record = new WebInspector.ResourceTimelineRecord(mainResource);
</ins><span class="cx">         if (!isNaN(record.startTime))
</span><span class="cx">             this._persistentNetworkTimeline.addRecord(record);
</span><span class="cx"> 
</span><span class="lines">@@ -687,13 +756,13 @@
</span><span class="cx">         if (!WebInspector.frameResourceManager.mainFrame)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        if (this._startAutoCapturing(event))
</del><ins>+        if (this._attemptAutoCapturingForFrame(frame))
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         if (!this._isCapturing)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        if (mainResource === this._autoCapturingMainResource)
</del><ins>+        if (mainResource === this._mainResourceForAutoCapturing)
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         this._addRecord(record);
</span><span class="lines">@@ -891,6 +960,39 @@
</span><span class="cx">         // However, the remaining ScriptProfiler records are valid and could be shown.
</span><span class="cx">         // FIXME: &lt;https://webkit.org/b/152904&gt; Web Inspector: Timeline UI should keep up with processing all incoming records
</span><span class="cx">     }
</span><ins>+
+    _updateAutoCaptureInstruments()
+    {
+        if (!window.TimelineAgent)
+            return;
+
+        if (!TimelineAgent.setAutoCaptureInstruments)
+            return;
+
+        let instrumentSet = new Set;
+        let enabledTimelineTypes = this._enabledTimelineTypesSetting.value;
+
+        for (let timelineType of enabledTimelineTypes) {
+            switch (timelineType) {
+            case WebInspector.TimelineRecord.Type.Script:
+                instrumentSet.add(TimelineAgent.Instrument.ScriptProfiler);
+                break;
+            case WebInspector.TimelineRecord.Type.HeapAllocations:
+                instrumentSet.add(TimelineAgent.Instrument.Heap);
+                break;
+            case WebInspector.TimelineRecord.Type.Network:
+            case WebInspector.TimelineRecord.Type.RenderingFrame:
+            case WebInspector.TimelineRecord.Type.Layout:
+                instrumentSet.add(TimelineAgent.Instrument.Timeline);
+                break;
+            case WebInspector.TimelineRecord.Type.Memory:
+                instrumentSet.add(TimelineAgent.Instrument.Memory);
+                break;
+            }
+        }
+
+        TimelineAgent.setAutoCaptureInstruments([...instrumentSet]);
+    }
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> WebInspector.TimelineManager.Event = {
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebInspectorUIUserInterfaceProtocolTimelineObserverjs"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebInspectorUI/UserInterface/Protocol/TimelineObserver.js (201147 => 201148)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebInspectorUI/UserInterface/Protocol/TimelineObserver.js        2016-05-19 08:40:55 UTC (rev 201147)
+++ branches/safari-602.1.32-branch/Source/WebInspectorUI/UserInterface/Protocol/TimelineObserver.js        2016-05-19 08:41:03 UTC (rev 201148)
</span><span class="lines">@@ -41,4 +41,9 @@
</span><span class="cx">     {
</span><span class="cx">         WebInspector.timelineManager.capturingStopped(endTime);
</span><span class="cx">     }
</span><ins>+
+    autoCaptureStarted()
+    {
+        WebInspector.timelineManager.autoCaptureStarted();
+    }
</ins><span class="cx"> };
</span></span></pre>
</div>
</div>

</body>
</html>