1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
android_webview / test / data / prerender-test-setup.js [blame]
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Objects starting with the "aw" prefix are injected by AwPrerenderTest.
function createIframe(url) {
const iframe = document.createElement('iframe');
iframe.setAttribute('src', url);
document.body.appendChild(iframe);
}
function wasActivated() {
return self.performance?.getEntriesByType?.('navigation')[0]
?.activationStart > 0;
}
const wasPrerendered = document.prerendering || wasActivated();
if (wasActivated()) {
awActivationFuture.activated();
} else {
document.onprerenderingchange = () => awActivationFuture.activated();
}
// Notify the primary page that this prerendered page started.
window.localStorage.setItem('pageStarted', location.href);