Commit 6f5978f2 authored by Liquan(Max) Gu's avatar Liquan(Max) Gu Committed by Commit Bot

[DomInteractive] Mark Dom interactive to media document and image document

According to the spec (https://html.spec.whatwg.org/multipage/browsing-the-web.html#read-media),
"Then, the user agent must act as if it had stopped parsing", so we mark
DOM-interactive to Media Document when finishes parsing.

Bug: 845385
Change-Id: I825409e9cf4c8d11f1f9233844492cc3a0bebe9a
Reviewed-on: https://chromium-review.googlesource.com/1239516Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Liquan (Max) Gǔ <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594494}
parent c8409826
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test domInteractive on image document.</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#read-media"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<script>
const t = async_test("Test domInteractive on image document");
function frameLoaded() {
const timing = document.querySelector("iframe").contentWindow.performance.timing;
assert_greater_than(timing.domInteractive, 0,
"Expect domInteractive to be positive value.");
t.done();
}
</script>
<body>
<h1>Description</h1>
<p>This tests that a image document has positive-value domInteractive.</p>
<iframe src="../images/smiley.png" onload="frameLoaded()"></iframe>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test domInteractive on media document.</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#read-media"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<script>
const t = async_test("Test domInteractive on media document");
function frameLoaded() {
const timing = document.querySelector("iframe").contentWindow.performance.timing;
assert_greater_than(timing.domInteractive, 0,
"Expect domInteractive to be positive value.");
t.done();
}
</script>
<body>
<h1>Description</h1>
<p>This tests that a media document has positive-value domInteractive.</p>
<iframe src="../media/A4.mp4" onload="frameLoaded()"></iframe>
</body>
</html>
\ No newline at end of file
......@@ -37,8 +37,10 @@ class RawDataDocumentParser : public DocumentParser {
: DocumentParser(document) {}
void Finish() override {
if (!IsStopped())
if (!IsStopped()) {
GetDocument()->SetReadyState(Document::kInteractive);
GetDocument()->FinishedParsing();
}
}
private:
......
......@@ -177,8 +177,10 @@ void ImageDocumentParser::Finish() {
GetDocument()->ImageLoaded();
}
if (!IsDetached())
if (!IsDetached()) {
GetDocument()->SetReadyState(Document::kInteractive);
GetDocument()->FinishedParsing();
}
}
// --------
......
......@@ -214,6 +214,11 @@ TEST_F(ImageDocumentTest, ImageCenteredWithoutForceZeroLayoutHeight) {
EXPECT_EQ(50, ImageHeight());
}
TEST_F(ImageDocumentTest, DomInteractive) {
CreateDocument(25, 30);
EXPECT_FALSE(GetDocument().GetTiming().DomInteractive().is_null());
}
#if defined(OS_ANDROID)
#define MAYBE(test) DISABLED_##test
#else
......
......@@ -462,4 +462,8 @@ TEST_P(HTMLMediaElementTest, VisibilityObserverCreatedForLazyLoad) {
EXPECT_EQ(HasLazyLoadObserver(), GetParam() == MediaTestParam::kVideo);
}
TEST_P(HTMLMediaElementTest, DomInteractive) {
EXPECT_FALSE(Media()->GetDocument().GetTiming().DomInteractive().is_null());
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment