2010-11-04 James Simonsen <simonjam@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Nov 2010 08:36:17 +0000 (08:36 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Nov 2010 08:36:17 +0000 (08:36 +0000)
        Reviewed by Darin Fisher.

        [Web Timing] Implement dom* timing marks
        https://bugs.webkit.org/show_bug.cgi?id=46301

        * fast/dom/Window/window-properties-performance-expected.txt:
        * fast/dom/script-tests/webtiming-async.js: Added.
        * fast/dom/script-tests/webtiming-defer.js: Added.
        * fast/dom/script-tests/webtiming-document-open.js: Added.
        (testTimingWithDocumentOpen):
        * fast/dom/script-tests/webtiming-navigate-within-document.js:
        (checkTimingNotChanged): Added dom timing.
        * fast/dom/script-tests/webtiming.js:
        (checkTimingBeforeLoad): Added dom timing.
        (checkTimingWhileDeferred): Added.
        (checkWebTimingWhileAsync): Added.
        (checkWebTimingOnLoad): Added dom timing.
        (checkWebTimingAfterLoad): Added dom timing.
        * fast/dom/webtiming-document-open-expected.txt: Added.
        * fast/dom/webtiming-document-open.html: Added.
        * fast/dom/webtiming-expected.txt:
        * fast/dom/webtiming-navigate-within-document-expected.txt:
        * fast/dom/webtiming.html: Added async and defer tests.
        * platform/mac/Skipped: Skip new webtiming test.
2010-11-04  James Simonsen  <simonjam@chromium.org>

        Reviewed by Darin Fisher.

        [Web Timing] Implement dom* timing marks
        https://bugs.webkit.org/show_bug.cgi?id=46301

        Test: fast/dom/webtiming-document-open.html

        * GNUmakefile.am: Added DocumentTiming.h
        * WebCore.gypi: Ditto.
        * WebCore.vcproj/WebCore.vcproj: Ditto.
        * WebCore.xcodeproj/project.pbxproj: Ditto.
        * dom/Document.cpp:
        (WebCore::Document::setReadyState): Set DOM WebTiming marks.
        (WebCore::Document::finishedParsing): Set DOM WebTiming marks.
        * dom/Document.h:
        (WebCore::Document::timing): Added.
        * dom/DocumentTiming.h: Added.
        (WebCore::DocumentTiming::DocumentTiming):
        * page/Timing.cpp: Added DOM timing.
        (WebCore::Timing::domLoading): Ditto.
        (WebCore::Timing::domInteractive): Ditto.
        (WebCore::Timing::domContentLoaded): Ditto.
        (WebCore::Timing::domComplete): Ditto.
        (WebCore::Timing::documentTiming): Ditto.
        * page/Timing.h: Ditto.
        * page/Timing.idl: Ditto.

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

24 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Window/window-properties-performance-expected.txt
LayoutTests/fast/dom/script-tests/webtiming-async.js [new file with mode: 0644]
LayoutTests/fast/dom/script-tests/webtiming-defer.js [new file with mode: 0644]
LayoutTests/fast/dom/script-tests/webtiming-document-open.js [new file with mode: 0644]
LayoutTests/fast/dom/script-tests/webtiming-navigate-within-document.js
LayoutTests/fast/dom/script-tests/webtiming.js
LayoutTests/fast/dom/webtiming-document-open-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/webtiming-document-open.html [new file with mode: 0644]
LayoutTests/fast/dom/webtiming-expected.txt
LayoutTests/fast/dom/webtiming-navigate-within-document-expected.txt
LayoutTests/fast/dom/webtiming.html
LayoutTests/platform/mac/Skipped
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.gypi
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/dom/DocumentTiming.h [new file with mode: 0644]
WebCore/page/Timing.cpp
WebCore/page/Timing.h
WebCore/page/Timing.idl

index 55f081a..8221811 100644 (file)
@@ -1,3 +1,30 @@
+2010-11-04  James Simonsen  <simonjam@chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        [Web Timing] Implement dom* timing marks
+        https://bugs.webkit.org/show_bug.cgi?id=46301
+
+        * fast/dom/Window/window-properties-performance-expected.txt:
+        * fast/dom/script-tests/webtiming-async.js: Added.
+        * fast/dom/script-tests/webtiming-defer.js: Added.
+        * fast/dom/script-tests/webtiming-document-open.js: Added.
+        (testTimingWithDocumentOpen):
+        * fast/dom/script-tests/webtiming-navigate-within-document.js:
+        (checkTimingNotChanged): Added dom timing.
+        * fast/dom/script-tests/webtiming.js:
+        (checkTimingBeforeLoad): Added dom timing.
+        (checkTimingWhileDeferred): Added.
+        (checkWebTimingWhileAsync): Added.
+        (checkWebTimingOnLoad): Added dom timing.
+        (checkWebTimingAfterLoad): Added dom timing.
+        * fast/dom/webtiming-document-open-expected.txt: Added.
+        * fast/dom/webtiming-document-open.html: Added.
+        * fast/dom/webtiming-expected.txt:
+        * fast/dom/webtiming-navigate-within-document-expected.txt:
+        * fast/dom/webtiming.html: Added async and defer tests.
+        * platform/mac/Skipped: Skip new webtiming test.
+
 2010-11-03  Roland Steiner  <rolandsteiner@chromium.org>
 
         Unreviewed: add new entry to Chromium test_expectations.txt
index 146fd55..8bbabb0 100644 (file)
@@ -13,6 +13,10 @@ window.webkitPerformance.navigation.type [number]
 window.webkitPerformance.timing [object Timing]
 window.webkitPerformance.timing.connectEnd [number]
 window.webkitPerformance.timing.connectStart [number]
+window.webkitPerformance.timing.domComplete [number]
+window.webkitPerformance.timing.domContentLoaded [number]
+window.webkitPerformance.timing.domInteractive [number]
+window.webkitPerformance.timing.domLoading [number]
 window.webkitPerformance.timing.domainLookupEnd [number]
 window.webkitPerformance.timing.domainLookupStart [number]
 window.webkitPerformance.timing.fetchStart [number]
diff --git a/LayoutTests/fast/dom/script-tests/webtiming-async.js b/LayoutTests/fast/dom/script-tests/webtiming-async.js
new file mode 100644 (file)
index 0000000..ac336db
--- /dev/null
@@ -0,0 +1 @@
+checkWebTimingWhileAsync();
diff --git a/LayoutTests/fast/dom/script-tests/webtiming-defer.js b/LayoutTests/fast/dom/script-tests/webtiming-defer.js
new file mode 100644 (file)
index 0000000..1f89c53
--- /dev/null
@@ -0,0 +1 @@
+checkTimingWhileDeferred();
diff --git a/LayoutTests/fast/dom/script-tests/webtiming-document-open.js b/LayoutTests/fast/dom/script-tests/webtiming-document-open.js
new file mode 100644 (file)
index 0000000..d0679a2
--- /dev/null
@@ -0,0 +1,40 @@
+var performance = window.webkitPerformance || {};
+var navigation = performance.navigation || {};
+var timing = performance.timing || {};
+var originalTiming = {};
+
+window.addEventListener("load", testTimingWithDocumentOpen, false);
+
+function testTimingWithDocumentOpen()
+{
+    for (property in timing) {
+        originalTiming[property] = timing[property];
+    }
+
+    document.open();
+    document.write("<html>");
+    document.write("<head>");
+    document.write("<link rel=\"stylesheet\" href=\"../js/resources/js-test-style.css\">");
+    document.write("<script src=\"../js/resources/js-test-pre.js\"></script>");
+    document.write("</head>");
+    document.write("<body>");
+    document.write("<p id=\"description\"></p>");
+    document.write("<div id=\"console\"></div>");
+    document.write("<script src=\"../js/resources/js-test-post.js\"></script>");
+    document.write("</body>");
+    document.write("</html>");
+    document.close();
+
+    description("This test verifies that the NavigationTimings don't change after a document.open().");
+
+    keys = Object.keys(timing).sort();
+    for (var i = 0; i < keys.length; ++i) {
+        shouldBe("timing." + keys[i], "originalTiming." + keys[i]);
+    }
+
+    finishJSTest();
+}
+
+jsTestIsAsync = true;
+
+var successfullyParsed = true;
index ab583bd..b635305 100644 (file)
@@ -5,7 +5,9 @@ var timing = performance.timing || {};
 
 function checkTimingNotChanged()
 {
-    for (var property in timing) {
+    properties = Object.keys(timing).sort();
+    for (var i = 0; i < properties.length; ++i) {
+        property = properties[i];
         if (timing[property] === initialTiming[property])
             testPassed(property + " is unchanged.");
         else
index bae2134..29b206f 100644 (file)
@@ -38,6 +38,82 @@ function checkTimingBeforeLoad()
 
     shouldBe("timing.responseStart", "timing.requestEnd");
 
+    shouldBeGreaterThanOrEqual("timing.domLoading", "timing.fetchStart");
+    shouldBe("timing.domInteractive", "0");
+    shouldBe("timing.domContentLoaded", "0");
+    shouldBe("timing.domComplete", "0");
+
+    shouldBe("timing.loadEventStart", "0");
+    shouldBe("timing.loadEventEnd", "0");
+}
+
+function checkTimingWhileDeferred()
+{
+    shouldBeGreaterThanOrEqual("timing.navigationStart", "oneHourAgoUTC");
+
+    shouldBeGreaterThanOrEqual("timing.unloadEventEnd", "timing.navigationStart");
+
+    shouldBe("timing.redirectStart", "0");
+    shouldBe("timing.redirectEnd", "0");
+    shouldBe("navigation.redirectCount", "0");
+
+    shouldBeGreaterThanOrEqual("timing.fetchStart", "timing.navigationStart");
+
+    shouldBeGreaterThanOrEqual("timing.domainLookupStart", "timing.fetchStart");
+    shouldBeGreaterThanOrEqual("timing.domainLookupEnd", "timing.domainLookupStart");
+
+    shouldBeGreaterThanOrEqual("timing.connectStart", "timing.domainLookupEnd");
+    shouldBeGreaterThanOrEqual("timing.connectEnd", "timing.connectStart");
+
+    shouldBeGreaterThanOrEqual("timing.requestStart", "timing.connectEnd");
+    shouldBeGreaterThanOrEqual("timing.requestEnd", "timing.requestStart");
+
+    shouldBe("timing.responseStart", "timing.requestEnd");
+
+    shouldBeGreaterThanOrEqual("timing.domLoading", "timing.fetchStart");
+    shouldBeGreaterThanOrEqual("timing.domInteractive", "timing.domLoading");
+    shouldBe("timing.domContentLoaded", "0");
+    shouldBe("timing.domComplete", "0");
+
+    shouldBe("timing.loadEventStart", "0");
+    shouldBe("timing.loadEventEnd", "0");
+
+    var body = document.getElementsByTagName("body")[0];
+    var script = document.createElement("script");
+    script.async = true;
+    script.type = "text/javascript";
+    script.src = "script-tests/webtiming-async.js";
+    body.appendChild(script);
+}
+
+function checkWebTimingWhileAsync()
+{
+    shouldBeGreaterThanOrEqual("timing.navigationStart", "oneHourAgoUTC");
+
+    shouldBeGreaterThanOrEqual("timing.unloadEventEnd", "timing.navigationStart");
+
+    shouldBe("timing.redirectStart", "0");
+    shouldBe("timing.redirectEnd", "0");
+    shouldBe("navigation.redirectCount", "0");
+
+    shouldBeGreaterThanOrEqual("timing.fetchStart", "timing.navigationStart");
+
+    shouldBeGreaterThanOrEqual("timing.domainLookupStart", "timing.fetchStart");
+    shouldBeGreaterThanOrEqual("timing.domainLookupEnd", "timing.domainLookupStart");
+
+    shouldBeGreaterThanOrEqual("timing.connectStart", "timing.domainLookupEnd");
+    shouldBeGreaterThanOrEqual("timing.connectEnd", "timing.connectStart");
+
+    shouldBeGreaterThanOrEqual("timing.requestStart", "timing.connectEnd");
+    shouldBeGreaterThanOrEqual("timing.requestEnd", "timing.requestStart");
+
+    shouldBe("timing.responseStart", "timing.requestEnd");
+
+    shouldBeGreaterThanOrEqual("timing.domLoading", "timing.fetchStart");
+    shouldBeGreaterThanOrEqual("timing.domInteractive", "timing.responseEnd");
+    shouldBeGreaterThanOrEqual("timing.domContentLoaded", "timing.domInteractive");
+    shouldBe("timing.domComplete", "0");
+
     shouldBe("timing.loadEventStart", "0");
     shouldBe("timing.loadEventEnd", "0");
 
@@ -68,6 +144,11 @@ function checkWebTimingOnLoad()
     shouldBe("timing.responseStart", "timing.requestEnd");
     shouldBeGreaterThanOrEqual("timing.responseEnd", "timing.responseStart");
 
+    shouldBeGreaterThanOrEqual("timing.domLoading", "timing.fetchStart");
+    shouldBeGreaterThanOrEqual("timing.domInteractive", "timing.responseEnd");
+    shouldBeGreaterThanOrEqual("timing.domContentLoaded", "timing.domInteractive");
+    shouldBeGreaterThanOrEqual("timing.domComplete", "timing.domContentLoaded");
+
     shouldBeGreaterThanOrEqual("timing.loadEventStart", "timing.responseEnd");
     shouldBe("timing.loadEventEnd", "0");
 
@@ -98,6 +179,11 @@ function checkWebTimingAfterLoad()
     shouldBe("timing.responseStart", "timing.requestEnd");
     shouldBeGreaterThanOrEqual("timing.responseEnd", "timing.responseStart");
 
+    shouldBeGreaterThanOrEqual("timing.domLoading", "timing.fetchStart");
+    shouldBeGreaterThanOrEqual("timing.domInteractive", "timing.responseEnd");
+    shouldBeGreaterThanOrEqual("timing.domContentLoaded", "timing.domInteractive");
+    shouldBeGreaterThanOrEqual("timing.domComplete", "timing.domContentLoaded");
+
     shouldBeGreaterThanOrEqual("timing.loadEventStart", "timing.responseEnd");
     shouldBeGreaterThanOrEqual("timing.loadEventEnd", "timing.loadEventStart + 50");
 
diff --git a/LayoutTests/fast/dom/webtiming-document-open-expected.txt b/LayoutTests/fast/dom/webtiming-document-open-expected.txt
new file mode 100644 (file)
index 0000000..0fc8249
--- /dev/null
@@ -0,0 +1,27 @@
+This test verifies that the NavigationTimings don't change after a document.open().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS timing.connectEnd is originalTiming.connectEnd
+PASS timing.connectStart is originalTiming.connectStart
+PASS timing.domComplete is originalTiming.domComplete
+PASS timing.domContentLoaded is originalTiming.domContentLoaded
+PASS timing.domInteractive is originalTiming.domInteractive
+PASS timing.domLoading is originalTiming.domLoading
+PASS timing.domainLookupEnd is originalTiming.domainLookupEnd
+PASS timing.domainLookupStart is originalTiming.domainLookupStart
+PASS timing.fetchStart is originalTiming.fetchStart
+PASS timing.loadEventEnd is originalTiming.loadEventEnd
+PASS timing.loadEventStart is originalTiming.loadEventStart
+PASS timing.navigationStart is originalTiming.navigationStart
+PASS timing.redirectEnd is originalTiming.redirectEnd
+PASS timing.redirectStart is originalTiming.redirectStart
+PASS timing.requestEnd is originalTiming.requestEnd
+PASS timing.requestStart is originalTiming.requestStart
+PASS timing.responseEnd is originalTiming.responseEnd
+PASS timing.responseStart is originalTiming.responseStart
+PASS timing.unloadEventEnd is originalTiming.unloadEventEnd
+PASS successfullyParsed is true
+
+TEST COMPLETE
diff --git a/LayoutTests/fast/dom/webtiming-document-open.html b/LayoutTests/fast/dom/webtiming-document-open.html
new file mode 100644 (file)
index 0000000..be95de8
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/webtiming-document-open.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 4e169f8..af7faea 100644 (file)
@@ -16,6 +16,48 @@ PASS timing.connectEnd is >= timing.connectStart
 PASS timing.requestStart is >= timing.connectEnd
 PASS timing.requestEnd is >= timing.requestStart
 PASS timing.responseStart is timing.requestEnd
+PASS timing.domLoading is >= timing.fetchStart
+PASS timing.domInteractive is 0
+PASS timing.domContentLoaded is 0
+PASS timing.domComplete is 0
+PASS timing.loadEventStart is 0
+PASS timing.loadEventEnd is 0
+PASS timing.navigationStart is >= oneHourAgoUTC
+PASS timing.unloadEventEnd is >= timing.navigationStart
+PASS timing.redirectStart is 0
+PASS timing.redirectEnd is 0
+PASS navigation.redirectCount is 0
+PASS timing.fetchStart is >= timing.navigationStart
+PASS timing.domainLookupStart is >= timing.fetchStart
+PASS timing.domainLookupEnd is >= timing.domainLookupStart
+PASS timing.connectStart is >= timing.domainLookupEnd
+PASS timing.connectEnd is >= timing.connectStart
+PASS timing.requestStart is >= timing.connectEnd
+PASS timing.requestEnd is >= timing.requestStart
+PASS timing.responseStart is timing.requestEnd
+PASS timing.domLoading is >= timing.fetchStart
+PASS timing.domInteractive is >= timing.domLoading
+PASS timing.domContentLoaded is 0
+PASS timing.domComplete is 0
+PASS timing.loadEventStart is 0
+PASS timing.loadEventEnd is 0
+PASS timing.navigationStart is >= oneHourAgoUTC
+PASS timing.unloadEventEnd is >= timing.navigationStart
+PASS timing.redirectStart is 0
+PASS timing.redirectEnd is 0
+PASS navigation.redirectCount is 0
+PASS timing.fetchStart is >= timing.navigationStart
+PASS timing.domainLookupStart is >= timing.fetchStart
+PASS timing.domainLookupEnd is >= timing.domainLookupStart
+PASS timing.connectStart is >= timing.domainLookupEnd
+PASS timing.connectEnd is >= timing.connectStart
+PASS timing.requestStart is >= timing.connectEnd
+PASS timing.requestEnd is >= timing.requestStart
+PASS timing.responseStart is timing.requestEnd
+PASS timing.domLoading is >= timing.fetchStart
+PASS timing.domInteractive is >= timing.responseEnd
+PASS timing.domContentLoaded is >= timing.domInteractive
+PASS timing.domComplete is 0
 PASS timing.loadEventStart is 0
 PASS timing.loadEventEnd is 0
 PASS timing.navigationStart is >= oneHourAgoUTC
@@ -32,6 +74,10 @@ PASS timing.requestStart is >= timing.connectEnd
 PASS timing.requestEnd is >= timing.requestStart
 PASS timing.responseStart is timing.requestEnd
 PASS timing.responseEnd is >= timing.responseStart
+PASS timing.domLoading is >= timing.fetchStart
+PASS timing.domInteractive is >= timing.responseEnd
+PASS timing.domContentLoaded is >= timing.domInteractive
+PASS timing.domComplete is >= timing.domContentLoaded
 PASS timing.loadEventStart is >= timing.responseEnd
 PASS timing.loadEventEnd is 0
 PASS timing.navigationStart is >= oneHourAgoUTC
@@ -48,6 +94,10 @@ PASS timing.requestStart is >= timing.connectEnd
 PASS timing.requestEnd is >= timing.requestStart
 PASS timing.responseStart is timing.requestEnd
 PASS timing.responseEnd is >= timing.responseStart
+PASS timing.domLoading is >= timing.fetchStart
+PASS timing.domInteractive is >= timing.responseEnd
+PASS timing.domContentLoaded is >= timing.domInteractive
+PASS timing.domComplete is >= timing.domContentLoaded
 PASS timing.loadEventStart is >= timing.responseEnd
 PASS timing.loadEventEnd is >= timing.loadEventStart + 50
 PASS successfullyParsed is true
index 22aefd2..cfcadaa 100644 (file)
@@ -3,21 +3,25 @@ This test checks that navigating within the document does not reset Web Timing n
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS requestEnd is unchanged.
-PASS responseStart is unchanged.
-PASS connectStart is unchanged.
-PASS domainLookupStart is unchanged.
 PASS connectEnd is unchanged.
-PASS responseEnd is unchanged.
-PASS requestStart is unchanged.
-PASS navigationStart is unchanged.
-PASS loadEventEnd is unchanged.
-PASS redirectStart is unchanged.
+PASS connectStart is unchanged.
+PASS domComplete is unchanged.
+PASS domContentLoaded is unchanged.
+PASS domInteractive is unchanged.
+PASS domLoading is unchanged.
 PASS domainLookupEnd is unchanged.
-PASS unloadEventEnd is unchanged.
+PASS domainLookupStart is unchanged.
 PASS fetchStart is unchanged.
+PASS loadEventEnd is unchanged.
 PASS loadEventStart is unchanged.
+PASS navigationStart is unchanged.
 PASS redirectEnd is unchanged.
+PASS redirectStart is unchanged.
+PASS requestEnd is unchanged.
+PASS requestStart is unchanged.
+PASS responseEnd is unchanged.
+PASS responseStart is unchanged.
+PASS unloadEventEnd is unchanged.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 0db65c5..61f47c8 100644 (file)
@@ -8,6 +8,7 @@
 <p id="description"></p>
 <div id="console"></div>
 <script src="script-tests/webtiming.js"></script>
+<script src="script-tests/webtiming-defer.js" defer></script>
 <script src="../js/resources/js-test-post.js"></script>
 </body>
 </html>
index e000ba8..b063896 100644 (file)
@@ -211,6 +211,7 @@ fast/dom/navigation-type-back-forward.html
 fast/dom/navigation-type-navigate.html
 fast/dom/navigation-type-reload.html
 fast/dom/webtiming.html
+fast/dom/webtiming-document-open.html
 fast/dom/webtiming-navigate-within-document.html
 http/tests/misc/webtiming-one-redirect.php
 http/tests/misc/webtiming-two-redirects.php
index cd22e23..2e9288a 100644 (file)
@@ -1,3 +1,32 @@
+2010-11-04  James Simonsen  <simonjam@chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        [Web Timing] Implement dom* timing marks
+        https://bugs.webkit.org/show_bug.cgi?id=46301
+
+        Test: fast/dom/webtiming-document-open.html
+
+        * GNUmakefile.am: Added DocumentTiming.h
+        * WebCore.gypi: Ditto.
+        * WebCore.vcproj/WebCore.vcproj: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * dom/Document.cpp:
+        (WebCore::Document::setReadyState): Set DOM WebTiming marks.
+        (WebCore::Document::finishedParsing): Set DOM WebTiming marks.
+        * dom/Document.h:
+        (WebCore::Document::timing): Added.
+        * dom/DocumentTiming.h: Added.
+        (WebCore::DocumentTiming::DocumentTiming):
+        * page/Timing.cpp: Added DOM timing.
+        (WebCore::Timing::domLoading): Ditto.
+        (WebCore::Timing::domInteractive): Ditto.
+        (WebCore::Timing::domContentLoaded): Ditto.
+        (WebCore::Timing::domComplete): Ditto.
+        (WebCore::Timing::documentTiming): Ditto.
+        * page/Timing.h: Ditto.
+        * page/Timing.idl: Ditto.
+
 2010-11-04  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Reviewed by Martin Robinson.
index 95e0d1d..1134d89 100644 (file)
@@ -1109,6 +1109,7 @@ webcore_sources += \
        WebCore/dom/DocumentMarker.h \
        WebCore/dom/DocumentParser.cpp \
        WebCore/dom/DocumentParser.h \
+       WebCore/dom/DocumentTiming.h \
        WebCore/dom/DocumentType.cpp \
        WebCore/dom/DocumentType.h \
        WebCore/dom/DOMCoreException.h \
index 837dc3a..90c363d 100644 (file)
             'dom/DocumentMarkerController.h',
             'dom/DocumentParser.cpp',
             'dom/DocumentParser.h',
+            'dom/DocumentTiming.h',
             'dom/DocumentType.cpp',
             'dom/DocumentType.h',
             'dom/DynamicNodeList.cpp',
index 19a3674..e1277f1 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\dom\DocumentTiming.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\dom\DocumentType.cpp"\r
                                >\r
                                <FileConfiguration\r
index 49bdb30..70a59c8 100644 (file)
                85FF315A0AAFBFCB00374F38 /* DOMKeyboardEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 85FF31580AAFBFCB00374F38 /* DOMKeyboardEvent.h */; };
                85FF315B0AAFBFCB00374F38 /* DOMKeyboardEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85FF31590AAFBFCB00374F38 /* DOMKeyboardEvent.mm */; };
                86243D0111BC31F700CC006A /* JSArrayBufferViewHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 86243D0011BC31F700CC006A /* JSArrayBufferViewHelper.h */; };
+               86D982F7125C154000AD9E3D /* DocumentTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 86D982F6125C154000AD9E3D /* DocumentTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
                890AE0E11256A07900F5968C /* DirectoryReaderBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 890AE0E01256A07900F5968C /* DirectoryReaderBase.h */; };
                893C47A71238908B002B3D86 /* FileCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 893C47A51238908B002B3D86 /* FileCallback.h */; };
                893C47A81238908B002B3D86 /* FileWriterCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 893C47A61238908B002B3D86 /* FileWriterCallback.h */; };
                85FF31580AAFBFCB00374F38 /* DOMKeyboardEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMKeyboardEvent.h; sourceTree = "<group>"; };
                85FF31590AAFBFCB00374F38 /* DOMKeyboardEvent.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMKeyboardEvent.mm; sourceTree = "<group>"; };
                86243D0011BC31F700CC006A /* JSArrayBufferViewHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSArrayBufferViewHelper.h; sourceTree = "<group>"; };
+               86D982F6125C154000AD9E3D /* DocumentTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentTiming.h; sourceTree = "<group>"; };
                890AE0E01256A07900F5968C /* DirectoryReaderBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DirectoryReaderBase.h; path = fileapi/DirectoryReaderBase.h; sourceTree = "<group>"; };
                893C47A51238908B002B3D86 /* FileCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileCallback.h; path = fileapi/FileCallback.h; sourceTree = "<group>"; };
                893C47A61238908B002B3D86 /* FileWriterCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileWriterCallback.h; path = fileapi/FileWriterCallback.h; sourceTree = "<group>"; };
                                CE057FA41220731100A476D5 /* DocumentMarkerController.h */,
                                A8C2280D11D4A59700D5A7D3 /* DocumentParser.cpp */,
                                BCCFBAE70B5152ED0001F1D7 /* DocumentParser.h */,
+                               86D982F6125C154000AD9E3D /* DocumentTiming.h */,
                                A8185F3209765765005826D9 /* DocumentType.cpp */,
                                A8185F3109765765005826D9 /* DocumentType.h */,
                                93EEC1E809C2877700C515D1 /* DocumentType.idl */,
                                CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */,
                                BCCFBAE80B5152ED0001F1D7 /* DocumentParser.h in Headers */,
                                0B90561A0F2578BF0095FF6A /* DocumentThreadableLoader.h in Headers */,
+                               86D982F7125C154000AD9E3D /* DocumentTiming.h in Headers */,
                                A8185F3909765766005826D9 /* DocumentType.h in Headers */,
                                973889A1116EA9DC00ADF313 /* DocumentWriter.h in Headers */,
                                BC1A37AD097C715F0019F3D8 /* DOM.h in Headers */,
index 36b080a..1e71a95 100644 (file)
@@ -989,6 +989,22 @@ void Document::setReadyState(ReadyState readyState)
 {
     if (readyState == m_readyState)
         return;
+
+    switch (readyState) {
+    case Loading:
+        if (!m_documentTiming.domLoading)
+            m_documentTiming.domLoading = currentTime();
+        break;
+    case Interactive:
+        if (!m_documentTiming.domInteractive)
+            m_documentTiming.domInteractive = currentTime();
+        break;
+    case Complete:
+        if (!m_documentTiming.domComplete)
+            m_documentTiming.domComplete = currentTime();
+        break;
+    }
+
     m_readyState = readyState;
     dispatchEvent(Event::create(eventNames().readystatechangeEvent, false, false));
 }
@@ -4139,6 +4155,8 @@ void Document::finishedParsing()
     ASSERT(!scriptableDocumentParser() || !m_parser->isParsing());
     ASSERT(!scriptableDocumentParser() || m_readyState != Loading);
     setParsing(false);
+    if (!m_documentTiming.domContentLoaded)
+        m_documentTiming.domContentLoaded = currentTime();
     dispatchEvent(Event::create(eventNames().DOMContentLoadedEvent, true, false));
 
     if (Frame* f = frame()) {
index 1334aa3..c9e3b47 100644 (file)
@@ -33,6 +33,7 @@
 #include "Color.h"
 #include "ContainerNode.h"
 #include "DocumentMarkerController.h"
+#include "DocumentTiming.h"
 #include "QualifiedName.h"
 #include "ScriptExecutionContext.h"
 #include "Timer.h"
@@ -1045,6 +1046,8 @@ public:
     PassRefPtr<TouchList> createTouchList(ExceptionCode&) const;
 #endif
 
+    const DocumentTiming* timing() const { return &m_documentTiming; }
+
 protected:
     Document(Frame*, const KURL& url, bool isXHTML, bool isHTML, const KURL& baseURL = KURL());
 
@@ -1338,9 +1341,11 @@ private:
     Timer<Document> m_loadEventDelayTimer;
 
     ViewportArguments m_viewportArguments;
-    
+
     bool m_directionSetOnDocumentElement;
     bool m_writingModeSetOnDocumentElement;
+
+    DocumentTiming m_documentTiming;
 };
 
 inline bool Document::hasElementWithId(AtomicStringImpl* id) const
diff --git a/WebCore/dom/DocumentTiming.h b/WebCore/dom/DocumentTiming.h
new file mode 100644 (file)
index 0000000..a0bbb8c
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 Google, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GOOGLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef DocumentTiming_h
+#define DocumentTiming_h
+
+namespace WebCore {
+
+struct DocumentTiming {
+    DocumentTiming()
+        : domLoading(0.0)
+        , domInteractive(0.0)
+        , domContentLoaded(0.0)
+        , domComplete(0.0)
+    {
+    }
+
+    double domLoading;
+    double domInteractive;
+    double domContentLoaded;
+    double domComplete;
+};
+
+}
+
+#endif
index 8a0de2a..3d98dc2 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "DocumentLoadTiming.h"
 #include "DocumentLoader.h"
+#include "DocumentTiming.h"
 #include "Frame.h"
 #include "ResourceLoadTiming.h"
 #include "ResourceResponse.h"
@@ -246,6 +247,42 @@ unsigned long long Timing::responseEnd() const
     return toIntegerMilliseconds(timing->responseEnd);
 }
 
+unsigned long long Timing::domLoading() const
+{
+    const DocumentTiming* timing = documentTiming();
+    if (!timing)
+        return 0;
+
+    return toIntegerMilliseconds(timing->domLoading);
+}
+
+unsigned long long Timing::domInteractive() const
+{
+    const DocumentTiming* timing = documentTiming();
+    if (!timing)
+        return 0;
+
+    return toIntegerMilliseconds(timing->domInteractive);
+}
+
+unsigned long long Timing::domContentLoaded() const
+{
+    const DocumentTiming* timing = documentTiming();
+    if (!timing)
+        return 0;
+
+    return toIntegerMilliseconds(timing->domContentLoaded);
+}
+
+unsigned long long Timing::domComplete() const
+{
+    const DocumentTiming* timing = documentTiming();
+    if (!timing)
+        return 0;
+
+    return toIntegerMilliseconds(timing->domComplete);
+}
+
 unsigned long long Timing::loadEventStart() const
 {
     DocumentLoadTiming* timing = documentLoadTiming();
@@ -272,6 +309,18 @@ DocumentLoader* Timing::documentLoader() const
     return m_frame->loader()->documentLoader();
 }
 
+const DocumentTiming* Timing::documentTiming() const
+{
+    if (!m_frame)
+        return 0;
+
+    Document* document = m_frame->document();
+    if (!document)
+        return 0;
+
+    return document->timing();
+}
+
 DocumentLoadTiming* Timing::documentLoadTiming() const
 {
     DocumentLoader* loader = documentLoader();
index f48f525..3e3485f 100644 (file)
@@ -40,6 +40,7 @@ namespace WebCore {
 
 struct DocumentLoadTiming;
 class DocumentLoader;
+struct DocumentTiming;
 class Frame;
 class ResourceLoadTiming;
 
@@ -63,12 +64,17 @@ public:
     unsigned long long requestEnd() const;
     unsigned long long responseStart() const;
     unsigned long long responseEnd() const;
+    unsigned long long domLoading() const;
+    unsigned long long domInteractive() const;
+    unsigned long long domContentLoaded() const;
+    unsigned long long domComplete() const;
     unsigned long long loadEventStart() const;
     unsigned long long loadEventEnd() const;
 
 private:
     Timing(Frame*);
 
+    const DocumentTiming* documentTiming() const;
     DocumentLoader* documentLoader() const;
     DocumentLoadTiming* documentLoadTiming() const;
     ResourceLoadTiming* resourceLoadTiming() const;
index e7e46cc..00d3e24 100644 (file)
@@ -45,6 +45,10 @@ module window {
         readonly attribute unsigned long long requestEnd;
         readonly attribute unsigned long long responseStart;
         readonly attribute unsigned long long responseEnd;
+        readonly attribute unsigned long long domLoading;
+        readonly attribute unsigned long long domInteractive;
+        readonly attribute unsigned long long domContentLoaded;
+        readonly attribute unsigned long long domComplete;
         readonly attribute unsigned long long loadEventStart;
         readonly attribute unsigned long long loadEventEnd;
     };