Commit c8c811ae authored by Nicolás Peña Moreno's avatar Nicolás Peña Moreno Committed by Commit Bot

Gate Longtasks and PaintTiming tests under assert_precondition

Change-Id: I5716c032afe345989397e655370c3b294a251f2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2018172Reviewed-by: default avatarTom McKee <tommckee@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734950}
parent b49c7c19
async_test(function (t) {
if (typeof PerformanceLongTaskTiming === 'undefined') {
assert_unreached("Longtasks are not supported.");
t.done();
}
assert_precondition(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
new PerformanceObserver(
t.step_func_done(entryList => {
const entries = entryList.getEntries();
......
......@@ -10,10 +10,7 @@
<div id="log"></div>
<script>
async_test(function (t) {
if (typeof PerformanceLongTaskTiming === 'undefined') {
assert_unreached("Longtasks are not supported.");
t.done();
}
assert_precondition(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
const observer = new PerformanceObserver(
t.step_func(function (entryList) {
const entries = entryList.getEntries();
......
......@@ -10,10 +10,7 @@
<div id="log"></div>
<script>
async_test(function (t) {
if (typeof PerformanceLongTaskTiming === 'undefined') {
assert_unreached("Longtasks are not supported.");
t.done();
}
assert_precondition(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
const observer = new PerformanceObserver(
t.step_func(function (entryList) {
const entries = entryList.getEntries();
......
......@@ -11,10 +11,7 @@
<script>
const initialTime = performance.now();
async_test(function (t) {
if (typeof PerformanceLongTaskTiming === 'undefined') {
assert_unreached("Longtasks are not supported.");
t.done();
}
assert_precondition(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
const observer = new PerformanceObserver(
t.step_func(function (entryList) {
const entries = entryList.getEntries();
......
......@@ -10,10 +10,7 @@
<div id="log"></div>
<script>
async_test(function (t) {
if (typeof PerformanceLongTaskTiming === 'undefined') {
assert_unreached("Longtasks are not supported.");
t.done();
}
assert_precondition(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
const observer = new PerformanceObserver(
t.step_func(function (entryList) {
const entries = entryList.getEntries();
......
......@@ -8,10 +8,7 @@
<script>
const t = async_test(t => {
if (typeof PerformanceLongTaskTiming === 'undefined') {
assert_unreached("Longtasks are not supported.");
t.done();
}
assert_precondition(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
window.addEventListener('message', t.step_func(e => {
assert_equals(e.data['entryType'], 'longtask');
assert_equals(e.data['frame-attribution'], 'same-origin-ancestor');
......
......@@ -10,10 +10,7 @@
<div id="log"></div>
<script>
async_test(function (t) {
if (typeof PerformanceLongTaskTiming === 'undefined') {
assert_unreached("Longtasks are not supported.");
t.done();
}
assert_precondition(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
const observer = new PerformanceObserver(
t.step_func(function (entryList) {
const entries = entryList.getEntries();
......
......@@ -8,10 +8,7 @@
<script>
async_test(t => {
if (typeof PerformanceLongTaskTiming === 'undefined') {
assert_unreached("Longtasks are not supported.");
t.done();
}
assert_precondition(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
window.addEventListener('message', t.step_func(e => {
assert_equals(e.data['entryType'], 'longtask');
assert_equals(e.data['frame-attribution'], 'cross-origin-unreachable');
......
......@@ -8,10 +8,7 @@
<script>
async_test(t => {
if (typeof PerformanceLongTaskTiming === 'undefined') {
assert_unreached("Longtasks are not supported.");
t.done();
}
assert_precondition(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
window.addEventListener('message', t.step_func(e => {
assert_equals(e.data['entryType'], 'longtask');
// Ignore any long task that may be produced by the top-level frame.
......
......@@ -7,10 +7,7 @@
<body>
<script>
async_test(function (t) {
if (typeof PerformanceLongTaskTiming === 'undefined') {
assert_unreached("Longtasks are not supported.");
t.done();
}
assert_precondition(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
const observer = new PerformanceObserver(
t.step_func(function (entryList) {
const entries = entryList.getEntries();
......
......@@ -11,10 +11,7 @@
This window opens a new window which contains a longtask. We test that the
longtask from the new window is not observed by the observer of this window. */
async_test(t => {
if (typeof PerformanceLongTaskTiming === 'undefined') {
assert_unreached("Longtasks are not supported.");
t.done();
}
assert_precondition(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
const observer = new PerformanceObserver(
t.step_func(function (entryList) {
const entries = entryList.getEntries();
......
test(() => {
if (typeof PerformanceObserver.supportedEntryTypes === "undefined")
assert_unreached("supportedEntryTypes is not supported.");
assert_precondition(typeof PerformanceObserver.supportedEntryTypes !== "undefined", 'supportedEntryTypes is not supported');
const types = PerformanceObserver.supportedEntryTypes;
assert_true(types.includes("longtask"),
"There should be 'longtask' in PerformanceObserver.supportedEntryTypes");
......@@ -20,10 +19,10 @@ function syncWait(waitDuration) {
return syncWait(waitDuration - (performance.now() - startTime));
}
if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
const entryType = "longtask";
if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
promise_test(async () => {
const entryType = "longtask";
promise_test(async () => {
assert_precondition(typeof PerformanceObserver.supportedEntryTypes !== "undefined", 'supportedEntryTypes is not supported');
assert_precondition(typeof PerformanceObserver.supportedEntryTypes.includes(entryType), `supportedEntryTypes does not include '${entryType}'`);
await new Promise((resolve) => {
new PerformanceObserver(function (list, observer) {
observer.disconnect();
......@@ -33,6 +32,4 @@ if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
// Force the PerformanceEntry.
syncWait(50);
})
}, `'${entryType}' entries should be observable.`)
}
}
}, `'${entryType}' entries should be observable.`)
......@@ -9,6 +9,7 @@
<script>
async_test(function(t) {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
t.step(function() {
const bufferedEntries = performance.getEntriesByType('paint');
assert_equals(bufferedEntries.length, 0, "No paint entries yet");
......
async_test(t => {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
// First observer creates second in callback to ensure the entry has been dispatched by the time
// the second observer begins observing.
let entries_seen = 0;
......
......@@ -5,6 +5,7 @@
<script>
async_test(function (t) {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
window.addEventListener('message', t.step_func(e => {
assert_equals(e.data, '2 paint first-paint paint first-contentful-paint');
// When only child frame paints, expect only first-paint.
......
......@@ -11,6 +11,7 @@
<footer>
<script>
async_test(function (t) {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
const body = document.getElementsByTagName('body')[0];
body.style.backgroundImage = 'url(resources/circles.png)';
window.onload = function() {
......
......@@ -9,6 +9,7 @@
<script>
async_test(function (t) {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
const canvas = document.getElementById("canvas");
const context = canvas.getContext("2d");
context.beginPath();
......
......@@ -9,6 +9,7 @@
<script>
async_test(function (t) {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
const img = document.createElement("IMG");
img.src = "resources/circles.png";
img.onload = function() {
......
......@@ -10,6 +10,7 @@
<script>
async_test(function (t) {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
const bufferedEntries = performance.getEntriesByType('paint');
assert_equals(bufferedEntries.length, 0, "No paint entries yet");
const div = document.createElement("div");
......
......@@ -9,6 +9,7 @@
<script>
async_test(function (t) {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
const img = document.createElement("IMG");
img.src = "resources/circle.svg";
img.onload = function() {
......
......@@ -9,6 +9,7 @@
<script>
async_test(function (t) {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
const iframe = document.createElement('iframe');
iframe.id = 'child-iframe';
iframe.src = 'resources/subframe-sending-paint.html';
......
......@@ -11,6 +11,7 @@
<footer>
<script>
async_test(function (t) {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
document.body.style.backgroundColor = "#AA0000";
function testPaintEntries() {
......
......@@ -9,6 +9,7 @@
<script>
async_test(function (t) {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
const div = document.createElement("div");
div.style.width = "100px";
div.style.height = "100px";
......
......@@ -9,7 +9,10 @@
<script src="/resources/testharnessreport.js"></script>
<a id="link" href="./">link</a>
<script>
/* This test ensures that an empty page is painted when there is an invisible visited link (that would be visible if the link was not visited). It's necessary that whether the page is painted or not does not depend on visitedness of the link. Otherwise the paint-timing API could be used to sniff whether a link has been visited or not. */
/* This test ensures that an empty page is painted when there is an invisible visited link (that
would be visible if the link was not visited). It's necessary that whether the page is painted or
not does not depend on visitedness of the link. Otherwise the paint-timing API could be used to
sniff whether a link has been visited or not. */
window.onload = function() {
/* Convenience helper to get the link into the browsing history.
Using a relative path because some browsers only allow replaceState within the same domain. */
......@@ -18,6 +21,7 @@ window.onload = function() {
history.replaceState({}, "", current_url);
}
async_test(function(t) {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
function testPaintEntries() {
const bufferedEntries = performance.getEntriesByType('paint');
if (bufferedEntries.length < 2) {
......
......@@ -6,6 +6,7 @@
<iframe id="listening-iframe" src="resources/subframe-sending-paint.html"></iframe>
<script>
async_test(function (t) {
assert_precondition(window.PerformancePaintTiming, "Paint Timing isn't supported.");
let paintingIframeHasDispatchedEntries = false;
window.addEventListener('message', t.step_func(e => {
if (!paintingIframeHasDispatchedEntries) {
......
test(() => {
if (typeof PerformanceObserver.supportedEntryTypes === "undefined")
assert_unreached("supportedEntryTypes is not supported.");
assert_precondition(typeof PerformanceObserver.supportedEntryTypes !== "undefined", 'supportedEntryTypes is not supported');
assert_true(PerformanceObserver.supportedEntryTypes.includes("paint"),
"There should be an entry 'paint' in PerformanceObserver.supportedEntryTypes");
}, "supportedEntryTypes contains 'paint'.");
if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
const entryType = 'paint';
if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
promise_test(async() => {
const entryType = 'paint';
promise_test(async() => {
assert_precondition(typeof PerformanceObserver.supportedEntryTypes !== "undefined", 'supportedEntryTypes is not supported');
assert_precondition(typeof PerformanceObserver.supportedEntryTypes.includes(entryType), `supportedEntryTypes does not include '${entryType}'`);
await new Promise((resolve) => {
new PerformanceObserver(function (list, observer) {
observer.disconnect();
......@@ -20,6 +19,4 @@ if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
if (self.document)
document.head.parentNode.appendChild(document.createTextNode('foo'));
})
}, `'${entryType}' entries should be observable.`)
}
}
}, `'${entryType}' entries should be observable.`)
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