2009-11-11 Eric Z. Ayers <zundel@google.com>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Nov 2009 19:51:11 +0000 (19:51 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Nov 2009 19:51:11 +0000 (19:51 +0000)
        Reviewed by Pavel Feldman.

        Added a test of an externally loaded script tag for Inspector
        timeline records.
        Fixed identity comparisons.

        https://bugs.webkit.org/show_bug.cgi?id=31365

        * inspector/timeline-script-tag-1.html:
        * inspector/timeline-script-tag-2-expected.txt: Added.
        * inspector/timeline-script-tag-2.html: Added.
        * inspector/timeline-script-tag-2.js: Added.
        * inspector/timeline-test.js:
        ():
        (timelineAgentTypeToString):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@50830 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/timeline-script-tag-1.html
LayoutTests/inspector/timeline-script-tag-2-expected.txt [new file with mode: 0644]
LayoutTests/inspector/timeline-script-tag-2.html [new file with mode: 0644]
LayoutTests/inspector/timeline-script-tag-2.js [new file with mode: 0644]
LayoutTests/inspector/timeline-test.js

index 8bbe97d..f584cb6 100644 (file)
@@ -1,3 +1,21 @@
+2009-11-11  Eric Z. Ayers  <zundel@google.com>
+
+        Reviewed by Pavel Feldman.
+
+        Added a test of an externally loaded script tag for Inspector 
+        timeline records.
+        Fixed identity comparisons.
+
+        https://bugs.webkit.org/show_bug.cgi?id=31365
+
+        * inspector/timeline-script-tag-1.html:
+        * inspector/timeline-script-tag-2-expected.txt: Added.
+        * inspector/timeline-script-tag-2.html: Added.
+        * inspector/timeline-script-tag-2.js: Added.
+        * inspector/timeline-test.js:
+        ():
+        (timelineAgentTypeToString):
+
 2009-11-11  Antonio Gomes  <tonikitoo@webkit.org>
 
         Rubber-stamped by Kenneth Christiansen.
index 9828f7f..f8ef7b7 100644 (file)
@@ -10,8 +10,8 @@ function analyzeEvaluateScript(record)
     var numChildren = record.children ? record.children.length : 0;
     for (var i = 0; i < numChildren; ++i) {
         var child = record.children[i];
-        if (child.type == timelineAgentRecordType.MarkTimeline
-            && child.data.message == timelineMark
+        if (child.type === timelineAgentRecordType.MarkTimeline
+            && child.data.message === timelineMark
             && record.data.url.indexOf("timeline-script-tag-1.html") !== -1) {
 
             // Finish printing the record as a tree
@@ -32,7 +32,7 @@ function analyzeParseHTML(record)
     var numChildren = record.children ? record.children.length : 0;
     for (var i = 0; i < numChildren; ++i) {
         var child = record.children[i];
-        if (child.type == timelineAgentRecordType.EvaluateScript)
+        if (child.type === timelineAgentRecordType.EvaluateScript)
             if (analyzeEvaluateScript(child))
                 return true;
     }
@@ -50,7 +50,7 @@ function analyzeTimelineData(timelineRecords)
     var numRecords = timelineRecords.length;
     for (var i = 0 ; i < numRecords; ++i) {
         var record = timelineRecords[i];
-        if (record.type == timelineAgentRecordType.ParseHTML) {
+        if (record.type === timelineAgentRecordType.ParseHTML) {
             // Uncomment to debug the ParseHTML data record
             // dumpTimelineRecord(record, 0);
             output("ParseHTML");
diff --git a/LayoutTests/inspector/timeline-script-tag-2-expected.txt b/LayoutTests/inspector/timeline-script-tag-2-expected.txt
new file mode 100644 (file)
index 0000000..1d21537
--- /dev/null
@@ -0,0 +1,16 @@
+Tests the Timeline API instrumentation of a script tag with an external script.
+
+ParseHTML
+----> EvaluateScript
+--------> MarkTimeline : SCRIPT TAG
+
+EvaluateScript Properties:
++ startTime : * DEFINED *
++ data : {
++- url : * DEFINED *
++- lineNumber : 1
++ }
++ children : * DEFINED *
++ endTime : * DEFINED *
++ type : 10
+
diff --git a/LayoutTests/inspector/timeline-script-tag-2.html b/LayoutTests/inspector/timeline-script-tag-2.html
new file mode 100644 (file)
index 0000000..196b65f
--- /dev/null
@@ -0,0 +1,77 @@
+<html>
+<head>
+<script src="inspector-test.js"></script>
+<script src="timeline-test.js"></script>
+<script>
+var timelineMark = "SCRIPT TAG";
+
+function analyzeEvaluateScript(record) 
+{
+    var numChildren = record.children ? record.children.length : 0;
+    for (var i = 0; i < numChildren; ++i) {
+        var child = record.children[i];
+        if (child.type === timelineAgentRecordType.MarkTimeline
+            && child.data.message === timelineMark
+            && record.data.url.indexOf("timeline-script-tag-2.js") !== -1) {
+
+            // Finish printing the record as a tree
+            dumpTimelineRecord(record, 1);
+            output("");
+
+            // Now print the important fields of the record
+            printTimelineRecordProperties(record);
+            return true;
+        }
+    }
+    return false;
+}
+
+function analyzeParseHTML(record) 
+{
+    var numChildren = record.children ? record.children.length : 0;
+    for (var i = 0; i < numChildren; ++i) {
+        var child = record.children[i];
+        if (child.type === timelineAgentRecordType.EvaluateScript)
+            if (analyzeEvaluateScript(child))
+                return true;
+    }
+    return false;
+}  
+
+// Look for the ParseHtml->EvaluateScript->MarkTimeline that correlates 
+// to the <script> tag below.
+function analyzeTimelineData(timelineRecords) 
+{
+    // Uncomment to debugging the list of data returned.
+    // dumpTimelineRecords(timelineRecords);
+
+    // Search for a ParseHTML record
+    var numRecords = timelineRecords.length;
+    for (var i = 0 ; i < numRecords; ++i) {
+        var record = timelineRecords[i];
+        if (record.type === timelineAgentRecordType.ParseHTML) {
+            // Uncomment to debug the ParseHTML data record
+            // dumpTimelineRecord(record, 0);
+            output("ParseHTML");
+            if (!analyzeParseHTML(record))
+                output("Failed to find timeline mark: " + timelineMark);
+        }
+    }
+}
+
+function doit() 
+{
+    retrieveTimelineData(analyzeTimelineData);
+}
+
+</script>
+</head>
+
+<body onload="onload()">
+<p>
+Tests the Timeline API instrumentation of a script tag with an external script.
+</p>
+
+<script src="timeline-script-tag-2.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/inspector/timeline-script-tag-2.js b/LayoutTests/inspector/timeline-script-tag-2.js
new file mode 100644 (file)
index 0000000..0fb273f
--- /dev/null
@@ -0,0 +1 @@
+console.markTimeline(timelineMark);
\ No newline at end of file
index 7d040fc..19865b2 100644 (file)
@@ -39,7 +39,7 @@ function dumpTimelineRecord(record, level)
         prefix = "----" + prefix;
     if (level > 0)
         prefix = prefix + "> ";
-    if (record.type == timelineAgentRecordType.MarkTimeline) {
+    if (record.type === timelineAgentRecordType.MarkTimeline) {
         suffix = " : " + record.data.message;
     }
     output(prefix + timelineAgentTypeToString(record.type) + suffix);
@@ -127,7 +127,7 @@ function markTimelineRecordAsOverhead(arg)
 function timelineAgentTypeToString(numericType)
 {
     for (var prop in timelineAgentRecordType) {
-        if (timelineAgentRecordType[prop] == numericType)
+        if (timelineAgentRecordType[prop] === numericType)
             return prop;
     }
     return undefined;