-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
test: update performance-timeline
wpt
#55197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
95 changes: 95 additions & 0 deletions
95
test/fixtures/wpt/performance-timeline/back-forward-cache-restoration.tentative.html
This file contains hidden or 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,95 @@ | ||
<!doctype html> | ||
<html> | ||
|
||
<head> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/dispatcher/dispatcher.js"></script> | ||
<script src="/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js"></script> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
const BackForwardCacheRestorationName = ''; | ||
const BackForwardCacheRestorationType = 'back-forward-cache-restoration'; | ||
|
||
let getNavigationId = (i) => { | ||
let identifier = 'mark' + i; | ||
performance.mark(identifier); | ||
return window.performance.getEntriesByName(identifier)[0].navigationId; | ||
} | ||
|
||
let getNumberofBackForwardCacheRestorationEntries = (BackForwardCacheRestorationType) => { | ||
return window.performance.getEntriesByType(BackForwardCacheRestorationType).length; | ||
} | ||
|
||
let getBackForwardCacheRestorationByType = (BackForwardCacheRestorationType) => { | ||
let entries = window.performance.getEntriesByType(BackForwardCacheRestorationType); | ||
return entries[entries.length - 1]; | ||
} | ||
|
||
let getBackForwardCacheRestorationByGetAllAndFilter = (BackForwardCacheRestorationType) => { | ||
let entries = window.performance.getEntries().filter(e => e.entryType == BackForwardCacheRestorationType); | ||
return entries[entries.length - 1]; | ||
} | ||
|
||
let getBackForwardCacheRestorationByPerformanceObserverBuffered = async (BackForwardCacheRestorationType) => { | ||
let p = new Promise(resolve => { | ||
new PerformanceObserver((list) => { | ||
const entries = list.getEntries().filter(e => e.entryType == BackForwardCacheRestorationType); | ||
if (entries.length > 0) { | ||
resolve(entries[entries.length - 1]); | ||
} | ||
}).observe({ type: BackForwardCacheRestorationType, buffered: true }); | ||
}); | ||
return await p; | ||
} | ||
|
||
let checkEntry = (entry, previousNavigationId) => { | ||
assert_equals(entry.name, BackForwardCacheRestorationName); | ||
assert_equals(entry.entryType, BackForwardCacheRestorationType); | ||
assert_not_equals(entry.navigationId, previousNavigationId); | ||
assert_true(entry.pageshowEventStart > entry.startTime); | ||
assert_true(entry.pageshowEventEnd >= entry.pageshowEventStart); | ||
} | ||
|
||
promise_test(async t => { | ||
const pageA = new RemoteContext(token()); | ||
const pageB = new RemoteContext(token()); | ||
|
||
const urlA = executorPath + pageA.context_id; | ||
const urlB = originCrossSite + executorPath + pageB.context_id; | ||
// Open url A. | ||
window.open(urlA, '_blank', 'noopener'); | ||
await pageA.execute_script(waitForPageShow); | ||
|
||
// Assert no instance of BackForwardCacheRestoration exists without back forward cache navigatoin. | ||
let size = await pageA.execute_script(getNumberofBackForwardCacheRestorationEntries); | ||
assert_equals(0, size); | ||
|
||
let entry; | ||
for (i = 0; i < 2; i++) { | ||
let curr_nav_id = await pageA.execute_script(getNavigationId, [i]); | ||
|
||
// Navigate away to url B and back. | ||
await navigateAndThenBack(pageA, pageB, urlB); | ||
|
||
// Assert Performance Observer API supports BackForwardCacheRestoration. | ||
entry = await pageA.execute_script(getBackForwardCacheRestorationByPerformanceObserverBuffered, [BackForwardCacheRestorationType]); | ||
// The navigation id after a bfcache restoration should be different | ||
// from that before. | ||
checkEntry(entry, curr_nav_id); | ||
|
||
// Assert Performance Timeline API supports BackForwardCacheRestoration. | ||
entry = await pageA.execute_script(getBackForwardCacheRestorationByType, [BackForwardCacheRestorationType]); | ||
checkEntry(entry, curr_nav_id); | ||
|
||
entry = await pageA.execute_script(getBackForwardCacheRestorationByGetAllAndFilter, [BackForwardCacheRestorationType]); | ||
checkEntry(entry, curr_nav_id); | ||
} | ||
}, 'Performance API for the back forward cache restoration entry.'); | ||
</script> | ||
</body> | ||
|
||
</html> |
81 changes: 81 additions & 0 deletions
81
test/fixtures/wpt/performance-timeline/droppedentriescount.any.js
This file contains hidden or 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,81 @@ | ||
promise_test(t => { | ||
// This setup is required for later tests as well. | ||
// Await for a dropped entry. | ||
return new Promise(res => { | ||
// Set a buffer size of 0 so that new resource entries count as dropped. | ||
performance.setResourceTimingBufferSize(0); | ||
// Use an observer to make sure the promise is resolved only when the | ||
// new entry has been created. | ||
new PerformanceObserver(res).observe({type: 'resource'}); | ||
fetch('resources/square.png?id=1'); | ||
}).then(() => { | ||
return new Promise(resolve => { | ||
new PerformanceObserver(t.step_func((entries, obs, options) => { | ||
assert_equals(options['droppedEntriesCount'], 0); | ||
resolve(); | ||
})).observe({type: 'mark'}); | ||
performance.mark('test'); | ||
})}); | ||
}, 'Dropped entries count is 0 when there are no dropped entries of relevant type.'); | ||
|
||
promise_test(async t => { | ||
return new Promise(resolve => { | ||
new PerformanceObserver(t.step_func((entries, obs, options) => { | ||
assert_equals(options['droppedEntriesCount'], 1); | ||
resolve(); | ||
})).observe({entryTypes: ['mark', 'resource']}); | ||
performance.mark('meow'); | ||
}); | ||
}, 'Dropped entries correctly counted with multiple types.'); | ||
|
||
promise_test(t => { | ||
return new Promise(resolve => { | ||
new PerformanceObserver(t.step_func((entries, obs, options) => { | ||
assert_equals(options['droppedEntriesCount'], 1, | ||
'There should have been some dropped resource timing entries at this point'); | ||
resolve(); | ||
})).observe({type: 'resource', buffered: true}); | ||
}); | ||
}, 'Dropped entries counted even if observer was not registered at the time.'); | ||
|
||
promise_test(t => { | ||
return new Promise(resolve => { | ||
let callback_ran = false; | ||
new PerformanceObserver(t.step_func((entries, obs, options) => { | ||
if (!callback_ran) { | ||
assert_equals(options['droppedEntriesCount'], 2, | ||
'There should be two dropped entries right now.'); | ||
fetch('resources/square.png?id=3'); | ||
callback_ran = true; | ||
} else { | ||
assert_equals(options['droppedEntriesCount'], undefined, | ||
'droppedEntriesCount should be unset after the first callback!'); | ||
resolve(); | ||
} | ||
})).observe({type: 'resource'}); | ||
fetch('resources/square.png?id=2'); | ||
}); | ||
}, 'Dropped entries only surfaced on the first callback.'); | ||
|
||
|
||
promise_test(t => { | ||
return new Promise(resolve => { | ||
let callback_ran = false; | ||
let droppedEntriesCount = -1; | ||
new PerformanceObserver(t.step_func((entries, obs, options) => { | ||
if (!callback_ran) { | ||
assert_greater_than(options['droppedEntriesCount'], 0, | ||
'There should be several dropped entries right now.'); | ||
droppedEntriesCount = options['droppedEntriesCount']; | ||
callback_ran = true; | ||
obs.observe({type: 'mark'}); | ||
performance.mark('woof'); | ||
} else { | ||
assert_equals(options['droppedEntriesCount'], droppedEntriesCount, | ||
'There should be droppedEntriesCount due to the new observe().'); | ||
resolve(); | ||
} | ||
})).observe({type: 'resource'}); | ||
fetch('resources/square.png?id=4'); | ||
}); | ||
}, 'Dropped entries surfaced after an observe() call!'); |
2 changes: 2 additions & 0 deletions
2
test/fixtures/wpt/performance-timeline/idlharness-shadowrealm.window.js
This file contains hidden or 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,2 @@ | ||
// META: script=/resources/idlharness-shadowrealm.js | ||
idl_test_shadowrealm(["performance-timeline"], ["hr-time", "dom"]); |
30 changes: 30 additions & 0 deletions
30
test/fixtures/wpt/performance-timeline/navigation-id-detached-frame.tentative.html
This file contains hidden or 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,30 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>The navigation_id Detached iframe Parent Page.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
promise_test(t => { | ||
return new Promise(resolve => { | ||
const frame = document.createElement("iframe"); | ||
frame.addEventListener("load", async () => { | ||
// Wait for iframe to be detached. | ||
while (frame.contentWindow) { | ||
await new Promise(r => t.step_timeout(r, 10)); | ||
} | ||
resolve(); | ||
}); | ||
frame.src = "resources/navigation-id-detached-frame-page.html"; | ||
document.body.appendChild(frame); | ||
}); | ||
}, "The navigation_id getter does not crash a window of detached frame"); | ||
</script> | ||
</body> | ||
|
||
</html> |
14 changes: 14 additions & 0 deletions
14
test/fixtures/wpt/performance-timeline/navigation-id-element-timing.tentative.html
This file contains hidden or 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,14 @@ | ||
<!DOCTYPE HTML> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/dispatcher/dispatcher.js"></script> | ||
<script src="/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js"></script> | ||
<script src="navigation-id.helper.js"></script> | ||
<script> | ||
runNavigationIdTest({ | ||
navigationTimes: 3, | ||
testName: 'element_timing', | ||
}, "Element Timing navigation id test"); | ||
</script> |
49 changes: 49 additions & 0 deletions
49
test/fixtures/wpt/performance-timeline/navigation-id-initial-load.tentative.html
This file contains hidden or 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,49 @@ | ||
<!DOCTYPE HTML> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<!-- | ||
Navigation timing, LCP and paint timing entries are only emitted during initial | ||
load, not after a bfcache navigation. Therefore we only verify the existence of | ||
navigation id, not the increment. | ||
--> | ||
|
||
<body> | ||
<p>This text is to trigger a LCP entry emission.</p> | ||
<script> | ||
async function NavigationIdsFromLCP() { | ||
return new Promise(resolve => { | ||
new PerformanceObserver((entryList) => { | ||
resolve(entryList.getEntries()); | ||
}).observe({ type: 'largest-contentful-paint', buffered: true }); | ||
}) | ||
} | ||
|
||
promise_test(async t => { | ||
// Assert navigation id exists in LCP entries and and are all the same. | ||
const navigationIdsOfLCP = (await NavigationIdsFromLCP()).map(e => e.navigationId); | ||
assert_true(navigationIdsOfLCP.every(e => e == navigationIdsOfLCP[0]), | ||
'Navigation Ids of LCP entries should be the same at initial navigation'); | ||
|
||
// Assert navigation id exists in a NavigationTiming entry. | ||
const navigationIdOfNavigationTiming = | ||
performance.getEntriesByType('navigation')[0].navigationId; | ||
assert_true(!!navigationIdOfNavigationTiming, | ||
'Navigation Id of a navigation timing entry should exist at initial navigation'); | ||
|
||
// Assert navigation id exists in PaintTiming entries and are all the same. | ||
const navigationIdsOfPaintTiming = | ||
performance.getEntriesByType('paint').map(e => e.navigationId); | ||
assert_true(navigationIdsOfPaintTiming.every(e => | ||
e == navigationIdsOfPaintTiming[0]), | ||
'Navigation Id of PaintTiming entries should be the same as the initial navigation.'); | ||
|
||
// Assert navigation ids are all the same. | ||
const navigationIdsOfAll = | ||
navigationIdsOfLCP.concat(navigationIdsOfPaintTiming, navigationIdOfNavigationTiming); | ||
assert_true(navigationIdsOfAll.every(e => e == navigationIdsOfAll[0]), | ||
'Navigation Id of all entries should be the same as the initial navigation.'); | ||
|
||
}, 'Navigation Ids should exist and are all the same as the initial navigation.'); | ||
</script> | ||
</body> |
14 changes: 14 additions & 0 deletions
14
...fixtures/wpt/performance-timeline/navigation-id-long-task-task-attribution.tentative.html
This file contains hidden or 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,14 @@ | ||
<!DOCTYPE HTML> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/dispatcher/dispatcher.js"></script> | ||
<script src="/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js"></script> | ||
<script src="navigation-id.helper.js"></script> | ||
<script> | ||
runNavigationIdTest({ | ||
navigationTimes: 3, | ||
testName: 'long_task_task_attribution', | ||
}, "Long Task/Task Attribution navigation id test"); | ||
</script> |
14 changes: 14 additions & 0 deletions
14
test/fixtures/wpt/performance-timeline/navigation-id-mark-measure.tentative.html
This file contains hidden or 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,14 @@ | ||
<!DOCTYPE HTML> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/dispatcher/dispatcher.js"></script> | ||
<script src="/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js"></script> | ||
<script src="navigation-id.helper.js"></script> | ||
<script> | ||
runNavigationIdTest({ | ||
navigationTimes: 3, | ||
testName: 'mark_measure', | ||
}, "Mark/Measure navigation id test"); | ||
</script> |
53 changes: 53 additions & 0 deletions
53
test/fixtures/wpt/performance-timeline/navigation-id-reset.tentative.html
This file contains hidden or 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,53 @@ | ||
<!DOCTYPE HTML> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/dispatcher/dispatcher.js"></script> | ||
<script src="/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js"></script> | ||
<script> | ||
const reload = () => { | ||
window.location.reload(); | ||
}; | ||
|
||
const getNavigationId = () => { | ||
window.performance.mark('initial_load'); | ||
let entries = window.performance.getEntriesByType('mark'); | ||
return entries[entries.length - 1].navigationId; | ||
} | ||
|
||
promise_test(async t => { | ||
const pageA = new RemoteContext(token()); | ||
const pageB = new RemoteContext(token()); | ||
|
||
const urlA = executorPath + pageA.context_id; | ||
const urlB = originCrossSite + executorPath + pageB.context_id; | ||
// Open url A. | ||
window.open(urlA, '_blank', 'noopener') | ||
await pageA.execute_script(waitForPageShow); | ||
|
||
let navigationIdInitial = await pageA.execute_script(getNavigationId); | ||
|
||
// Navigate away to url B and back. | ||
await navigateAndThenBack(pageA, pageB, urlB); | ||
|
||
// Assert navigation id is re-generated and thus different when the | ||
// document is load from bfcache. | ||
navigationIdAfterBFCacheNav = await pageA.execute_script(getNavigationId); | ||
assert_not_equals(navigationIdInitial, navigationIdAfterBFCacheNav, 'Navigation Id should be \ | ||
re-generated and different from the previous one after back-forward-cache navigation.'); | ||
|
||
// Reload page. | ||
await pageA.execute_script(reload); | ||
await pageA.execute_script(waitForPageShow); | ||
|
||
navigationIdAfterReset = await pageA.execute_script(getNavigationId); | ||
|
||
assert_not_equals(navigationIdAfterReset, navigationIdAfterBFCacheNav, 'Navigation Id should\ | ||
be re-generated after reload which is different from the previous one.'); | ||
|
||
assert_not_equals(navigationIdAfterReset, navigationIdInitial, 'Navigation Id should\ | ||
be re-generated after reload which is different from the one of the initial load.'); | ||
|
||
}, 'Navigation Id should be re-generated after reload.'); | ||
</script> |
14 changes: 14 additions & 0 deletions
14
test/fixtures/wpt/performance-timeline/navigation-id-resource-timing.tentative.html
This file contains hidden or 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,14 @@ | ||
<!DOCTYPE HTML> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/dispatcher/dispatcher.js"></script> | ||
<script src="/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js"></script> | ||
<script src="navigation-id.helper.js"></script> | ||
<script> | ||
runNavigationIdTest({ | ||
navigationTimes: 3, | ||
testName: 'resource_timing', | ||
}, "Resource Timing navigation id test"); | ||
</script> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.