Skip to content

Commit

Permalink
Use assert_precondition in ElementTiming/LargestContentfulPaint
Browse files Browse the repository at this point in the history
This CL replaces assert_unreached for assert_precondition for the API
existence checks in the ElementTiming and LargestContentfulPaint WPTs.

Change-Id: Icd2ff3e045835cf4c46a370a384455143a717308
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2013863
Reviewed-by: Tom McKee <tommckee@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734494}
  • Loading branch information
npm1 authored and chromium-wpt-export-bot committed Jan 23, 2020
1 parent 025c749 commit bd2c049
Show file tree
Hide file tree
Showing 60 changed files with 63 additions and 180 deletions.
4 changes: 1 addition & 3 deletions element-timing/background-image-data-uri.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
<script>
let beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/background-image-multiple-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
let beforeRender = performance.now();
let numObservedElements = 0;
let observedDiv1 = false;
Expand Down
4 changes: 1 addition & 3 deletions element-timing/background-image-stretched.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
<script>
let beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/buffer-before-onload.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
is available from the observer with the buffered flag set to true.
*/
async_test(function(t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
beforeRender = performance.now();
const img = document.createElement('img');
img.src = 'resources/square20.jpg';
Expand Down
4 changes: 1 addition & 3 deletions element-timing/buffered-flag.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test(t => {
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const beforeRender = performance.now();
const img = document.createElement('img');
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
// Initial observer used to know when entry has been dispatched
new PerformanceObserver(() => {
// Second observer should require buffered flag to receive the already-dispatched entry.
Expand Down
4 changes: 1 addition & 3 deletions element-timing/cross-origin-element.sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test((t) => {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
let img;
const pathname = 'http://{{domains[www]}}:{{ports[http][1]}}'
+ '/element-timing/resources/square100.png';
Expand Down
4 changes: 1 addition & 3 deletions element-timing/cross-origin-iframe-element.sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test((t) => {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done((entryList) => {
assert_unreached("We should not observe a cross origin element.");
Expand Down
4 changes: 1 addition & 3 deletions element-timing/css-generated-text.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
<script>
async_test(function (t) {
const beforeRender = performance.now();
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/disconnect-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
let beforeRender;
let img;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
3 changes: 3 additions & 0 deletions element-timing/element-only-when-fully-active.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<iframe src="resources/iframe-stores-entry.html" id="ifr"></iframe>
<script>
let t = async_test('Only expose element attribute for fully active documents');
t.step(() => {
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
});
window.triggerTest = t.step_func_done(elementEntry => {
assert_not_equals(elementEntry.element, null);
const iframe = document.getElementById('ifr');
Expand Down
4 changes: 1 addition & 3 deletions element-timing/first-letter-background.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
<script>
let beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const div = document.getElementById('target');
let textObserved = false;
let imageObserved = false;
Expand Down
4 changes: 1 addition & 3 deletions element-timing/fixed-id-identifier.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
<p elementtiming='my_identifier' id='my_id'>Text</p>
<script>
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/image-TAO.sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test(t => {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const beforeRender = performance.now();
const remote_img = 'http://{{domains[www]}}:{{ports[http][1]}}/element-timing/resources/TAOImage.py?'
+ 'origin=' + window.location.origin +'&tao=';
Expand Down
4 changes: 1 addition & 3 deletions element-timing/image-carousel.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

<script>
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const beforeRenderTimes = [];
let entry_count = 0;
const entry_count_per_element = [0, 0];
Expand Down
4 changes: 1 addition & 3 deletions element-timing/image-clipped-svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<script>
let beforeRender;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/image-data-uri.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
<script>
let beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/image-not-added.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(() => {
// The image should not have caused an entry, so fail test.
Expand Down
4 changes: 1 addition & 3 deletions element-timing/image-not-fully-visible.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
let beforeRender;
let img;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/image-rect-iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
<script src="/resources/testharnessreport.js"></script>
<script>
async_test((t) => {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
on_event(window, 'message', e => {
assert_equals(e.data.length, 1);
assert_equals(e.data.entryType, 'element');
Expand Down
4 changes: 1 addition & 3 deletions element-timing/image-src-change.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
<img src='resources/square100.png' elementtiming='my_image' id='my_id'/>
<script>
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
let beforeRender = performance.now();
const img = document.getElementById('my_id');
let firstCallback = true;
Expand Down
4 changes: 1 addition & 3 deletions element-timing/image-with-css-scale.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
<script>
const beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/image-with-rotation.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
<script>
const beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/images-repeated-resource.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
let img;
let img2;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/invisible-images.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
</style>
<script>
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done((entries) => {
// The image should not have caused an entry, so fail test.
Expand Down
4 changes: 1 addition & 3 deletions element-timing/multiple-background-images.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
<script>
let beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
let numObservedElements = 0;
let observedCircle = false;
let observedSquare = false;
Expand Down
4 changes: 1 addition & 3 deletions element-timing/observe-background-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
<script>
let beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/observe-child-element.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test((t) => {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done((entryList) => {
assert_unreached("Should not have received an entry!");
Expand Down
4 changes: 1 addition & 3 deletions element-timing/observe-elementtiming.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
let beforeRender;
let img;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/observe-empty-attribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<script>
let beforeRender;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
let observedImage = false;
let observedText = false;
const observer = new PerformanceObserver(
Expand Down
4 changes: 1 addition & 3 deletions element-timing/observe-multiple-images.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
<script>
let beforeRender, image1Observed=0, image2Observed=0, image3Observed=0;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func(function(entryList) {
entryList.getEntries().forEach( entry => {
Expand Down
4 changes: 1 addition & 3 deletions element-timing/observe-shadow-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
<div id='target'></div>
<script>
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_unreached('Should not observe elements in shadow trees!');
Expand Down
4 changes: 1 addition & 3 deletions element-timing/observe-shadow-text.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
<div id='target'></div>
<script>
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_unreached('Should not observe text elements in shadow trees!');
Expand Down
4 changes: 1 addition & 3 deletions element-timing/observe-svg-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<script>
let beforeRender;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/observe-text.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test((t) => {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
let paragraph;
let beforeRender;
const observer = new PerformanceObserver(
Expand Down
4 changes: 1 addition & 3 deletions element-timing/observe-video-poster.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<script>
let beforeRender;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down
4 changes: 1 addition & 3 deletions element-timing/progressively-loaded-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
let numInitial = 75;
let sleep = 500;
async_test(function(t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const img_src = 'resources/progressive-image.py?name=square20.jpg&numInitial='
+ numInitial + '&sleep=' + sleep;
const observer = new PerformanceObserver(
Expand Down
Loading

0 comments on commit bd2c049

Please sign in to comment.