Skip to content

Commit

Permalink
Add a precondition to all the element timing tests
Browse files Browse the repository at this point in the history
Since PerformanceObserver.observe doesn't have any way to signal an
unsupported type we end up just timing out all the tests in
implementations that doesn't support element timing. For efficiency
add a precondition to all the tests to check for the relevant API instead.
  • Loading branch information
jgraham committed May 18, 2019
1 parent e90af5a commit 163424c
Show file tree
Hide file tree
Showing 29 changed files with 87 additions and 0 deletions.
3 changes: 3 additions & 0 deletions element-timing/background-image-data-uri.html
Expand Up @@ -18,6 +18,9 @@
<script>
let beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/background-image-multiple-elements.html
Expand Up @@ -23,6 +23,9 @@
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
let beforeRender = performance.now();
let numObservedElements = 0;
let observedDiv1 = false;
Expand Down
3 changes: 3 additions & 0 deletions element-timing/background-image-stretched.html
Expand Up @@ -18,6 +18,9 @@
<script>
let beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/buffer-before-onload.html
Expand Up @@ -14,6 +14,9 @@
the performance timeline.
*/
async_test(function(t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
beforeRender = performance.now();
const img = document.createElement('img');
img.src = 'resources/square20.jpg';
Expand Down
3 changes: 3 additions & 0 deletions element-timing/cross-origin-element.sub.html
Expand Up @@ -12,6 +12,9 @@
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test((t) => {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
let img;
const pathname = 'http://{{domains[www]}}:{{ports[http][1]}}'
+ '/element-timing/resources/square100.png';
Expand Down
3 changes: 3 additions & 0 deletions element-timing/cross-origin-iframe-element.sub.html
Expand Up @@ -7,6 +7,9 @@
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test((t) => {
if (!window.PerformanceElementTiming) {
assert_unreached("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
3 changes: 3 additions & 0 deletions element-timing/disconnect-image.html
Expand Up @@ -9,6 +9,9 @@
let beforeRender;
let img;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/image-TAO-wildcard.sub.html
Expand Up @@ -12,6 +12,9 @@
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test((t) => {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
let beforeRender;
let img;
const img_src = 'http://{{domains[www]}}:{{ports[http][1]}}/element-timing/'
Expand Down
3 changes: 3 additions & 0 deletions element-timing/image-carousel.html
Expand Up @@ -26,6 +26,9 @@

<script>
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
const beforeRenderTimes = [];
let entry_count = 0;
const entry_count_per_element = [0, 0];
Expand Down
3 changes: 3 additions & 0 deletions element-timing/image-clipped-svg.html
Expand Up @@ -7,6 +7,9 @@
<script>
let beforeRender;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/image-data-uri.html
Expand Up @@ -16,6 +16,9 @@
<script>
let beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/image-not-added.html
Expand Up @@ -5,6 +5,9 @@
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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
3 changes: 3 additions & 0 deletions element-timing/image-not-fully-visible.html
Expand Up @@ -14,6 +14,9 @@
let beforeRender;
let img;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/image-rect-iframe.html
Expand Up @@ -11,6 +11,9 @@
<script src="/resources/testharnessreport.js"></script>
<script>
async_test((t) => {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
on_event(window, 'message', e => {
assert_equals(e.data.length, 1);
assert_equals(e.data.entryType, 'element');
Expand Down
3 changes: 3 additions & 0 deletions element-timing/image-with-css-scale.html
Expand Up @@ -21,6 +21,9 @@
<script>
const beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/image-with-rotation.html
Expand Up @@ -21,6 +21,9 @@
<script>
const beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/images-repeated-resource.html
Expand Up @@ -21,6 +21,9 @@
const pathname = window.location.href.substring(0, index) +
'/resources/square100.png';
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
const observer = new PerformanceObserver(
t.step_func(function(entryList) {
entryList.getEntries().forEach(entry => {
Expand Down
3 changes: 3 additions & 0 deletions element-timing/invisible-images.html
Expand Up @@ -16,6 +16,9 @@
</style>
<script>
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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
3 changes: 3 additions & 0 deletions element-timing/multiple-background-images.html
Expand Up @@ -18,6 +18,9 @@
<script>
let beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
let numObservedElements = 0;
let observedCircle = false;
let observedSquare = false;
Expand Down
3 changes: 3 additions & 0 deletions element-timing/observe-background-image.html
Expand Up @@ -18,6 +18,9 @@
<script>
let beforeRender = performance.now();
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/observe-child-element.html
Expand Up @@ -12,6 +12,9 @@
<script src="resources/element-timing-helpers.js"></script>
<script>
async_test((t) => {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
const observer = new PerformanceObserver(
t.step_func_done((entryList) => {
assert_unreached("Should not have received an entry!");
Expand Down
3 changes: 3 additions & 0 deletions element-timing/observe-elementtiming.html
Expand Up @@ -14,6 +14,9 @@
let beforeRender;
let img;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/observe-large-image.html
Expand Up @@ -14,6 +14,9 @@
let beforeRender;
let img;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/observe-multiple-images.html
Expand Up @@ -22,6 +22,9 @@
<script>
let beforeRender, image1Observed=0, image2Observed=0, image3Observed=0;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
const index = window.location.href.lastIndexOf('/');
const observer = new PerformanceObserver(
t.step_func(function(entryList) {
Expand Down
3 changes: 3 additions & 0 deletions element-timing/observe-shadow-image.html
Expand Up @@ -14,6 +14,9 @@
let beforeRender;
let img;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/observe-svg-image.html
Expand Up @@ -7,6 +7,9 @@
<script>
let beforeRender;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/observe-video-poster.html
Expand Up @@ -7,6 +7,9 @@
<script>
let beforeRender;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("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/progressively-loaded-image.html
Expand Up @@ -14,6 +14,9 @@
let numInitial = 75;
let sleep = 500;
async_test(function(t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
const img_src = 'resources/progressive-image.py?name=square20.jpg&numInitial='
+ numInitial + '&sleep=' + sleep;
const observer = new PerformanceObserver(
Expand Down
3 changes: 3 additions & 0 deletions element-timing/rectangular-image.html
Expand Up @@ -14,6 +14,9 @@
let beforeRender;
let img;
async_test(function (t) {
if (!window.PerformanceElementTiming) {
assert_unreached("PerformanceElementTiming is not implemented");
}
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
Expand Down

0 comments on commit 163424c

Please sign in to comment.