-
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 the test for the setting the attribute lazyload="off" on iframes and image elements, which should prevent those elements from being lazily loaded. Bug: 916260 Change-Id: I323faa31c7683663d0d0136a719cf83c25758ad6
- Loading branch information
1 parent
2ade7dc
commit 731a86d
Showing
7 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
loading/lazyload/attribute_off_iframe_cross_origin.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,48 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<title>Loading cross-origin 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> | ||
async_test(function(t) { | ||
window.addEventListener("load", t.step_func_done()); | ||
}, "Test that document load event is fired"); | ||
|
||
async_test(function(t) { | ||
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; | ||
})); | ||
window.addEventListener("load", t.step_func_done(function() { | ||
assert_true(has_in_viewport_iframe_loaded); | ||
})); | ||
}, "Test that the in-viewport iframe loads immediately."); | ||
|
||
async_test(function(t) { | ||
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_below_viewport_iframe_loaded); | ||
})); | ||
}, "Test that the below-viewport iframe loads immediately."); | ||
</script> |
48 changes: 48 additions & 0 deletions
48
loading/lazyload/attribute_off_iframe_same_origin.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,48 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<title>Loading same-origin 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="resources/subframe_1.html" width="200px" height="100px" lazyload="off"></iframe> | ||
<div style="height:10000px;"></div> | ||
<iframe id="below_viewport" src="resources/subframe_2.html" width="200px" height="100px" lazyload="off"></iframe> | ||
</body> | ||
|
||
<script> | ||
async_test(function(t) { | ||
window.addEventListener("load", t.step_func_done()); | ||
}, "Test that document load event is fired"); | ||
|
||
async_test(function(t) { | ||
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; | ||
})); | ||
window.addEventListener("load", t.step_func_done(function() { | ||
assert_true(has_in_viewport_iframe_loaded); | ||
})); | ||
}, "Test that the in-viewport iframe loads immediately."); | ||
|
||
async_test(function(t) { | ||
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_below_viewport_iframe_loaded); | ||
})); | ||
}, "Test that the below-viewport iframe loads immediately."); | ||
</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,48 @@ | ||
<!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> | ||
async_test(function(t) { | ||
window.addEventListener("load", t.step_func_done()); | ||
}, "Test that document load event is fired"); | ||
|
||
async_test(function(t) { | ||
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; | ||
})); | ||
window.addEventListener("load", t.step_func_done(function() { | ||
assert_true(has_in_viewport_image_loaded); | ||
})); | ||
}, "Test that the in-viewport image loads immediately."); | ||
|
||
async_test(function(t) { | ||
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_below_viewport_image_loaded); | ||
})); | ||
}, "Test that the below-viewport image loads immediately."); | ||
</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.
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> |