Skip to content

Commit c0aa33a

Browse files
authored
fix: Record resource timing after load event (#450)
1 parent faf4fbb commit c0aa33a

20 files changed

+1011
-1420
lines changed

app/blank.png

26 KB
Loading

app/delayed_image.html

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>RUM Integ Test</title>
5+
<script src="./loader_resource_event.js"></script>
6+
<link
7+
rel="icon"
8+
type="image/png"
9+
href="https://awsmedia.s3.amazonaws.com/favicon.ico"
10+
/>
11+
12+
<script>
13+
window.onload = function () {
14+
var scriptElement = document.createElement('img');
15+
scriptElement.src = 'blank.png';
16+
document.body.appendChild(scriptElement);
17+
};
18+
</script>
19+
20+
<script>
21+
// Common to all test pages
22+
function dispatch() {
23+
cwr('dispatch');
24+
}
25+
26+
function clearRequestResponse() {
27+
document.getElementById('request_url').innerText = '';
28+
document.getElementById('request_header').innerText = '';
29+
document.getElementById('request_body').innerText = '';
30+
31+
document.getElementById('response_status').innerText = '';
32+
document.getElementById('response_header').innerText = '';
33+
document.getElementById('response_body').innerText = '';
34+
}
35+
36+
// No other functions are needed since web vitals are reported after page load whenever the metric value is ready
37+
38+
function disable() {
39+
cwr('disable');
40+
}
41+
42+
function enable() {
43+
cwr('enable');
44+
}
45+
</script>
46+
47+
<script>
48+
function makePageHidden() {
49+
Object.defineProperty(document, 'visibilityState', {
50+
value: 'hidden',
51+
writable: true
52+
});
53+
Object.defineProperty(document, 'hidden', {
54+
value: true,
55+
writable: true
56+
});
57+
document.dispatchEvent(new Event('visibilitychange'));
58+
}
59+
</script>
60+
61+
<style>
62+
table {
63+
border-collapse: collapse;
64+
margin-top: 10px;
65+
margin-bottom: 10px;
66+
}
67+
68+
td,
69+
th {
70+
border: 1px solid black;
71+
text-align: left;
72+
padding: 8px;
73+
}
74+
</style>
75+
</head>
76+
<body>
77+
<p id="welcome">This application is used for RUM integ testing.</p>
78+
<hr />
79+
<button id="testButton">Test Button</button>
80+
<button id="makePageHidden" onclick="makePageHidden()">
81+
Make Page Hidden
82+
</button>
83+
<hr />
84+
<button id="disable" onclick="disable()">Disable</button>
85+
<button id="enable" onclick="enable()">Enable</button>
86+
<hr />
87+
<button id="dispatch" onclick="dispatch()">Dispatch</button>
88+
<button id="clearRequestResponse" onclick="clearRequestResponse()">
89+
Clear
90+
</button>
91+
<hr />
92+
<span id="request"></span>
93+
<span id="response"></span>
94+
<table>
95+
<tr>
96+
<td>Request URL</td>
97+
<td id="request_url"></td>
98+
</tr>
99+
<tr>
100+
<td>Request Header</td>
101+
<td id="request_header"></td>
102+
</tr>
103+
<tr>
104+
<td>Request Body</td>
105+
<td id="request_body"></td>
106+
</tr>
107+
</table>
108+
<table>
109+
<tr>
110+
<td>Response Status Code</td>
111+
<td id="response_status"></td>
112+
</tr>
113+
<tr>
114+
<td>Response Header</td>
115+
<td id="response_header"></td>
116+
</tr>
117+
<tr>
118+
<td>Response Body</td>
119+
<td id="response_body"></td>
120+
</tr>
121+
</table>
122+
<hr />
123+
</body>
124+
</html>

app/delayed_page.html

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,41 +57,6 @@
5757
/>
5858
</form>
5959
<br />
60-
<button id="button1">Test ClickEvent1</button>
61-
<button id="button2">Test ClickEvent2</button>
62-
<button id="createJSError" onclick="createJSError()">
63-
Create JS Error
64-
</button>
65-
<script>
66-
function createJSError() {
67-
// TypeError: null has no properties
68-
null.foo;
69-
}
70-
</script>
71-
<script>
72-
function createHTTPError() {
73-
var xhr = new XMLHttpRequest();
74-
xhr.open(
75-
'POST',
76-
'https://www.google-analytics.com/collect',
77-
true
78-
);
79-
xhr.setRequestHeader('Content-type', 'application/json');
80-
xhr.send();
81-
}
82-
</script>
83-
<script>
84-
function disallowCookies() {
85-
cwr('allowCookies', false);
86-
}
87-
</script>
88-
<button id="createHTTPError" onclick="createHTTPError()">
89-
Create HTTP Error
90-
</button>
91-
<button id="randomSessionClick">Random Session click</button>
92-
<button id="disallowCookies" onclick="disallowCookies()">
93-
Disallow Cookies
94-
</button>
9560
<span id="request"></span>
9661
<span id="response"></span>
9762
<table>
@@ -126,7 +91,7 @@
12691
window.onload = function () {
12792
var scriptElement = document.createElement('script');
12893
scriptElement.type = 'text/javascript';
129-
scriptElement.src = './loader_standard.js';
94+
scriptElement.src = './loader_navigation_event.js';
13095
document.head.appendChild(scriptElement);
13196
};
13297
</script>

app/unsupported_browser.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<script>
66
window.navigator.sendBeacon = undefined;
77
</script>
8-
<script src="./loader_js_error_event.js"></script>
98
<link
109
rel="icon"
1110
type="image/png"
@@ -33,6 +32,8 @@
3332
padding: 8px;
3433
}
3534
</style>
35+
36+
<script src="./loader_js_error_event.js"></script>
3637
</head>
3738
<body>
3839
<p id="welcome">This application is used for RUM integ testing.</p>

0 commit comments

Comments
 (0)