-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LazyLoad: Add external web platform tests for the lazyload attribute.
This CL includes tests for: - testing that images and iframes with the attribute lazyload="off" are loaded immediately - testing that images and iframes with other lazyload attribute values are loaded immediately when the attribute value is changed to "off" - testing that having images and iframes below the viewport with different lazyload attribute values doesn't endlessly block the window load event - testing that images and iframes with different lazyload attribute values that enter the viewport are loaded. Bug: 916260 Change-Id: I323faa31c7683663d0d0136a719cf83c25758ad6
- Loading branch information
1 parent
c2c2646
commit 3b29d61
Showing
22 changed files
with
678 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<title>Loading iframes with lazyload="off"</title> | ||
<link rel="author" title="Scott Little" href="mailto:[email protected]"> | ||
<link rel="help" href="https://github.com/whatwg/html/pull/3752"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<!-- | ||
Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed. | ||
--> | ||
|
||
<body> | ||
<iframe id="in_viewport" src="https://{{hosts[][www]}}:{{ports[https][0]}}/loading/lazyload/resources/subframe_1.html" width="200px" height="100px" lazyload="off"></iframe> | ||
<div style="height:10000px;"></div> | ||
<iframe id="below_viewport" src="https://{{hosts[][www]}}:{{ports[https][0]}}/loading/lazyload/resources/subframe_2.html" width="200px" height="100px" lazyload="off"></iframe> | ||
</body> | ||
|
||
<script> | ||
var t = async_test("Test that both iframes load immediately and block the window's load event."); | ||
|
||
var has_in_viewport_iframe_loaded = false; | ||
document.getElementById("in_viewport").addEventListener("load", | ||
t.step_func(function() { | ||
assert_false(has_in_viewport_iframe_loaded); | ||
has_in_viewport_iframe_loaded = true; | ||
})); | ||
|
||
var has_below_viewport_iframe_loaded = false; | ||
document.getElementById("below_viewport").addEventListener("load", | ||
t.step_func(function() { | ||
assert_false(has_below_viewport_iframe_loaded); | ||
has_below_viewport_iframe_loaded = true; | ||
})); | ||
|
||
window.addEventListener("load", t.step_func_done(function() { | ||
assert_true(has_in_viewport_iframe_loaded); | ||
assert_true(has_below_viewport_iframe_loaded); | ||
})); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<title>Loading images with lazyload="off"</title> | ||
<link rel="author" title="Scott Little" href="mailto:[email protected]"> | ||
<link rel="help" href="https://github.com/whatwg/html/pull/3752"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<!-- | ||
Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed. | ||
--> | ||
|
||
<body> | ||
<img id="in_viewport" src="resources/image_1.png" lazyload="off"> | ||
<div style="height:10000px;"></div> | ||
<img id="below_viewport" src="resources/image_2.png" lazyload="off"> | ||
</body> | ||
|
||
<script> | ||
var t = async_test("Test that both images load immediately and block the window's load event."); | ||
|
||
var has_in_viewport_image_loaded = false; | ||
document.getElementById("in_viewport").addEventListener("load", | ||
t.step_func(function() { | ||
assert_false(has_in_viewport_image_loaded); | ||
has_in_viewport_image_loaded = true; | ||
})); | ||
|
||
var has_below_viewport_image_loaded = false; | ||
document.getElementById("below_viewport").addEventListener("load", | ||
t.step_func(function() { | ||
assert_false(has_below_viewport_image_loaded); | ||
has_below_viewport_image_loaded = true; | ||
})); | ||
|
||
window.addEventListener("load", t.step_func_done(function() { | ||
assert_true(has_in_viewport_image_loaded); | ||
assert_true(has_below_viewport_image_loaded); | ||
})); | ||
</script> |
66 changes: 66 additions & 0 deletions
66
loading/lazyload/change_attribute_to_off_iframe.tentative.sub.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<title>Iframes load immediately when lazyload attribute is changed to "off"</title> | ||
<link rel="author" title="Scott Little" href="mailto:[email protected]"> | ||
<link rel="help" href="https://github.com/whatwg/html/pull/3752"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<!-- | ||
Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed. | ||
--> | ||
|
||
<body> | ||
<div style="height:10000px;"></div> | ||
<iframe id="attribute_unset" src="https://{{hosts[][www]}}:{{ports[https][0]}}/loading/lazyload/resources/subframe_1.html" width="200px" height="100px"></iframe> | ||
<iframe id="attribute_invalid" src="https://{{hosts[][www]}}:{{ports[https][0]}}/loading/lazyload/resources/subframe_2.html" width="200px" height="100px" lazyload="invalid_value"></iframe> | ||
<iframe id="attribute_auto" src="https://{{hosts[][www]}}:{{ports[https][0]}}/loading/lazyload/resources/subframe_3.html" width="200px" height="100px" lazyload="auto"></iframe> | ||
<iframe id="attribute_on" src="https://{{hosts[][www]}}:{{ports[https][0]}}/loading/lazyload/resources/subframe_4.html" width="200px" height="100px" lazyload="on"></iframe> | ||
</body> | ||
|
||
<script> | ||
var t = async_test("Test that below viewport iframes that have their lazyload attributes changed to off are loaded."); | ||
|
||
var has_attribute_unset_loaded = false; | ||
var has_attribute_invalid_loaded = false; | ||
var has_attribute_auto_loaded = false; | ||
var has_attribute_on_loaded = false; | ||
|
||
function checkIfDone() { | ||
if (has_attribute_unset_loaded && | ||
has_attribute_invalid_loaded && | ||
has_attribute_auto_loaded && | ||
has_attribute_on_loaded) { | ||
t.done(); | ||
} | ||
} | ||
|
||
document.getElementById("attribute_unset").addEventListener("load", t.step_func(function() { | ||
assert_false(has_attribute_unset_loaded); | ||
has_attribute_unset_loaded = true; | ||
checkIfDone(); | ||
})); | ||
document.getElementById("attribute_invalid").addEventListener("load", t.step_func(function() { | ||
assert_false(has_attribute_invalid_loaded); | ||
has_attribute_invalid_loaded = true; | ||
checkIfDone(); | ||
})); | ||
document.getElementById("attribute_auto").addEventListener("load", t.step_func(function() { | ||
assert_false(has_attribute_auto_loaded); | ||
has_attribute_auto_loaded = true; | ||
checkIfDone(); | ||
})); | ||
document.getElementById("attribute_on").addEventListener("load", t.step_func(function() { | ||
assert_false(has_attribute_on_loaded); | ||
has_attribute_on_loaded = true; | ||
checkIfDone(); | ||
})); | ||
|
||
window.addEventListener("load", t.step_func_done(function() { | ||
document.getElementById("attribute_unset").setAttribute("lazyload", "off"); | ||
document.getElementById("attribute_invalid").setAttribute("lazyload", "off"); | ||
document.getElementById("attribute_auto").setAttribute("lazyload", "off"); | ||
document.getElementById("attribute_on").setAttribute("lazyload", "off"); | ||
})); | ||
</script> |
66 changes: 66 additions & 0 deletions
66
loading/lazyload/change_attribute_to_off_image.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<title>Images load immediately when lazyload attribute is changed to "off"</title> | ||
<link rel="author" title="Scott Little" href="mailto:[email protected]"> | ||
<link rel="help" href="https://github.com/whatwg/html/pull/3752"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<!-- | ||
Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed. | ||
--> | ||
|
||
<body> | ||
<div style="height:10000px;"></div> | ||
<img id="attribute_unset" src="resources/image_1.png"> | ||
<img id="attribute_invalid" src="resources/image_2.png" lazyload="invalid_value"> | ||
<img id="attribute_auto" src="resources/image_3.png" lazyload="auto"> | ||
<img id="attribute_on" src="resources/image_4.png" lazyload="on"> | ||
</body> | ||
|
||
<script> | ||
var t = async_test("Test that a below viewport image that has its lazyload attribute changed to off is loaded."); | ||
|
||
var has_attribute_unset_loaded = false; | ||
var has_attribute_invalid_loaded = false; | ||
var has_attribute_auto_loaded = false; | ||
var has_attribute_on_loaded = false; | ||
|
||
function checkIfDone() { | ||
if (has_attribute_unset_loaded && | ||
has_attribute_invalid_loaded && | ||
has_attribute_auto_loaded && | ||
has_attribute_on_loaded) { | ||
t.done(); | ||
} | ||
} | ||
|
||
document.getElementById("attribute_unset").addEventListener("load", t.step_func(function() { | ||
assert_false(has_attribute_unset_loaded); | ||
has_attribute_unset_loaded = true; | ||
checkIfDone(); | ||
})); | ||
document.getElementById("attribute_invalid").addEventListener("load", t.step_func(function() { | ||
assert_false(has_attribute_invalid_loaded); | ||
has_attribute_invalid_loaded = true; | ||
checkIfDone(); | ||
})); | ||
document.getElementById("attribute_auto").addEventListener("load", t.step_func(function() { | ||
assert_false(has_attribute_auto_loaded); | ||
has_attribute_auto_loaded = true; | ||
checkIfDone(); | ||
})); | ||
document.getElementById("attribute_on").addEventListener("load", t.step_func(function() { | ||
assert_false(has_attribute_on_loaded); | ||
has_attribute_on_loaded = true; | ||
checkIfDone(); | ||
})); | ||
|
||
window.addEventListener("load", t.step_func_done(function() { | ||
document.getElementById("attribute_unset").setAttribute("lazyload", "off"); | ||
document.getElementById("attribute_invalid").setAttribute("lazyload", "off"); | ||
document.getElementById("attribute_auto").setAttribute("lazyload", "off"); | ||
document.getElementById("attribute_on").setAttribute("lazyload", "off"); | ||
})); | ||
</script> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<html> | ||
<body> | ||
<p>Subframe 1.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<html> | ||
<body> | ||
<p>Subframe 2.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<html> | ||
<body> | ||
<p>Subframe 3.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<html> | ||
<body> | ||
<p>Subframe 4.</p> | ||
</body> | ||
</html> |
47 changes: 47 additions & 0 deletions
47
loading/lazyload/scroll_to_attribute_auto_iframe.tentative.sub.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<title>Iframes with lazyload="auto" load when in the viewport</title> | ||
<link rel="author" title="Scott Little" href="mailto:[email protected]"> | ||
<link rel="help" href="https://github.com/whatwg/html/pull/3752"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<!-- | ||
Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed. | ||
--> | ||
|
||
<body> | ||
<iframe id="in_viewport" src="https://{{hosts[][www]}}:{{ports[https][0]}}/loading/lazyload/resources/subframe_1.html" width="200px" height="100px" lazyload="auto"></iframe> | ||
<div style="height:10000px;"></div> | ||
<iframe id="below_viewport" src="https://{{hosts[][www]}}:{{ports[https][0]}}/loading/lazyload/resources/subframe_2.html" width="200px" height="100px" lazyload="auto"></iframe> | ||
</body> | ||
|
||
<script> | ||
var t = async_test("Test that iframes with lazyload='auto' that enter the viewport get loaded."); | ||
|
||
var has_in_viewport_loaded = false; | ||
var has_below_viewport_loaded = false; | ||
|
||
document.getElementById("in_viewport").addEventListener("load", t.step_func(function() { | ||
assert_false(has_in_viewport_loaded); | ||
has_in_viewport_loaded = true; | ||
if (has_below_viewport_loaded) { | ||
// Note that the below_viewport element's load event could happen before | ||
// the window.load event occurs, if the browser decides to load it | ||
// immediately instead of lazily loading. This is valid behavior, so the | ||
// test has passed if the below_viewport element has loaded. | ||
t.done(); | ||
} else { | ||
document.getElementById("below_viewport").scrollIntoView(); | ||
} | ||
})); | ||
|
||
document.getElementById("below_viewport").addEventListener("load", t.step_func(function() { | ||
assert_false(has_below_viewport_loaded); | ||
has_below_viewport_loaded = true; | ||
if (has_in_viewport_loaded) { | ||
t.done(); | ||
} | ||
})); | ||
</script> |
47 changes: 47 additions & 0 deletions
47
loading/lazyload/scroll_to_attribute_auto_image.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<title>Images with lazyload="auto" load when in the viewport</title> | ||
<link rel="author" title="Scott Little" href="mailto:[email protected]"> | ||
<link rel="help" href="https://github.com/whatwg/html/pull/3752"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<!-- | ||
Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed. | ||
--> | ||
|
||
<body> | ||
<img id="in_viewport" src="resources/image_1.png" lazyload="auto"> | ||
<div style="height:10000px;"></div> | ||
<img id="below_viewport" src="resources/image_2.png" lazyload="auto"> | ||
</body> | ||
|
||
<script> | ||
var t = async_test("Test that images with lazyload='auto' that enter the viewport get loaded."); | ||
|
||
var has_in_viewport_loaded = false; | ||
var has_below_viewport_loaded = false; | ||
|
||
document.getElementById("in_viewport").addEventListener("load", t.step_func(function() { | ||
assert_false(has_in_viewport_loaded); | ||
has_in_viewport_loaded = true; | ||
if (has_below_viewport_loaded) { | ||
// Note that the below_viewport element's load event could happen before | ||
// the window.load event occurs, if the browser decides to load it | ||
// immediately instead of lazily loading. This is valid behavior, so the | ||
// test has passed if the below_viewport element has loaded. | ||
t.done(); | ||
} else { | ||
document.getElementById("below_viewport").scrollIntoView(); | ||
} | ||
})); | ||
|
||
document.getElementById("below_viewport").addEventListener("load", t.step_func(function() { | ||
assert_false(has_below_viewport_loaded); | ||
has_below_viewport_loaded = true; | ||
if (has_in_viewport_loaded) { | ||
t.done(); | ||
} | ||
})); | ||
</script> |
47 changes: 47 additions & 0 deletions
47
loading/lazyload/scroll_to_attribute_invalid_iframe.tentative.sub.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<title>Iframes with invalid values for lazyload attributes load when in the viewport</title> | ||
<link rel="author" title="Scott Little" href="mailto:[email protected]"> | ||
<link rel="help" href="https://github.com/whatwg/html/pull/3752"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<!-- | ||
Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed. | ||
--> | ||
|
||
<body> | ||
<iframe id="in_viewport" src="https://{{hosts[][www]}}:{{ports[https][0]}}/loading/lazyload/resources/subframe_1.html" width="200px" height="100px" lazyload="invalid_value"></iframe> | ||
<div style="height:10000px;"></div> | ||
<iframe id="below_viewport" src="https://{{hosts[][www]}}:{{ports[https][0]}}/loading/lazyload/resources/subframe_2.html" width="200px" height="100px" lazyload="invalid_value"></iframe> | ||
</body> | ||
|
||
<script> | ||
var t = async_test("Test that iframes with invalid values for lazyload attributes that enter the viewport get loaded."); | ||
|
||
var has_in_viewport_loaded = false; | ||
var has_below_viewport_loaded = false; | ||
|
||
document.getElementById("in_viewport").addEventListener("load", t.step_func(function() { | ||
assert_false(has_in_viewport_loaded); | ||
has_in_viewport_loaded = true; | ||
if (has_below_viewport_loaded) { | ||
// Note that the below_viewport element's load event could happen before | ||
// the window.load event occurs, if the browser decides to load it | ||
// immediately instead of lazily loading. This is valid behavior, so the | ||
// test has passed if the below_viewport element has loaded. | ||
t.done(); | ||
} else { | ||
document.getElementById("below_viewport").scrollIntoView(); | ||
} | ||
})); | ||
|
||
document.getElementById("below_viewport").addEventListener("load", t.step_func(function() { | ||
assert_false(has_below_viewport_loaded); | ||
has_below_viewport_loaded = true; | ||
if (has_in_viewport_loaded) { | ||
t.done(); | ||
} | ||
})); | ||
</script> |
Oops, something went wrong.