Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector/service-workers/service-workers-navigation-preload.html

Issue 2620463002: Show service worker navigation preload requests in DevTools Network tab (Closed)
Patch Set: incorporated falken's comment Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/inspector/service-workers/service-workers-navigation-preload.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/service-workers/service-workers-navigation-preload.html b/third_party/WebKit/LayoutTests/http/tests/inspector/service-workers/service-workers-navigation-preload.html
new file mode 100644
index 0000000000000000000000000000000000000000..5445041ad6865bb086b9fd1d7489907b1bf38842
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/service-workers/service-workers-navigation-preload.html
@@ -0,0 +1,123 @@
+<html>
+<head>
+<script src="../inspector-test.js"></script>
+<script src="service-workers-test.js"></script>
+<script>
+
+function initializeServiceWorker(script, scope) {
+ return navigator.serviceWorker.register(script, {scope: scope})
+ .then(reg => waitForActivated(reg.installing));
+}
+
+function waitForActivated(worker) {
+ if (worker.state === 'activated')
+ return Promise.resolve();
+ if (worker.state === 'redundant')
+ return Promise.reject(new Error('The worker is redundant'));
+ return new Promise(resolve => {
+ worker.addEventListener('statechange', _ => {
+ if (worker.state === 'activated')
+ resolve();
+ });
+ });
+}
+
+function loadIframe(url)
+{
+ var callback;
+ var promise = new Promise((fulfill) => callback = fulfill);
+ var frame = document.createElement('iframe');
+ frame.src = url;
+ frame.onload = callback;
+ document.body.appendChild(frame);
+ return promise;
+}
+
+function test()
+{
+ var scriptURL = "http://127.0.0.1:8000/inspector/service-workers/resources/navigation-preload-worker.php";
+ var scope = "http://127.0.0.1:8000/inspector/service-workers/resources/navigation-preload-scope.php";
+
+ InspectorTest.addSniffer(SDK.NetworkDispatcher.prototype,
+ "navigationPreloadSent",
+ navigationPreloadSent,
+ true);
+ InspectorTest.addSniffer(SDK.NetworkDispatcher.prototype,
+ "navigationPreloadResponseReceived",
+ navigationPreloadResponseReceived,
+ true);
+ InspectorTest.addSniffer(SDK.NetworkDispatcher.prototype,
+ "navigationPreloadFailed",
+ navigationPreloadFailed,
+ true);
+ InspectorTest.addSniffer(SDK.NetworkDispatcher.prototype,
+ "navigationPreloadFinished",
+ navigationPreloadFinished,
+ true);
+
+ function navigationPreloadSent(requestId, url, timestamp, wallTime, initiator)
+ {
+ InspectorTest.addResult("navigationPreloadSent:");
+ InspectorTest.addResult(" url: " + url);
+ InspectorTest.addResult(" initiator.type: " + initiator.type);
+ }
+ function navigationPreloadResponseReceived(requestId, timestamp, response)
+ {
+ InspectorTest.addResult("navigationPreloadResponseReceived:");
+ InspectorTest.addResult(" response.url: " + response.url);
+ InspectorTest.addResult(" response.timing available: " +
+ !!response.timing);
+ InspectorTest.addResult(" response.requestHeaders available: " +
+ !!response.requestHeaders);
+ if (response.requestHeaders) {
+ InspectorTest.addResult(
+ " response.requestHeaders['Service-Worker-Navigation-Preload']: " +
+ response.requestHeaders['Service-Worker-Navigation-Preload']);
+ }
+
+ }
+ function navigationPreloadFailed(requestId, timestamp, errorMessage)
+ {
+ InspectorTest.addResult("navigationPreloadFailed:");
+ InspectorTest.addResult(" errorMessage: " + errorMessage);
+ }
+ function navigationPreloadFinished(requestId, timestamp)
+ {
+ InspectorTest.addResult("navigationPreloadFinished:");
+ }
+
+ InspectorTest.callFunctionInPageAsync("initializeServiceWorker",
+ [ scriptURL, scope ])
+ .then(_ => {
+ InspectorTest.addResult("-----------------");
+ InspectorTest.addResult("Loading an iframe.");
+ return InspectorTest.callFunctionInPageAsync("loadIframe", [ scope ]);
+ })
+ .then(_ => {
+ InspectorTest.addResult("The iframe loaded.");
+ InspectorTest.addResult("-----------------");
+ InspectorTest.addResult("Loading another iframe.");
+ return InspectorTest.callFunctionInPageAsync(
+ "loadIframe", [ scope + "?BrokenCunked"]);
falken 2017/01/18 14:50:07 Chunked
horo 2017/01/19 09:57:09 Done.
+ })
+ .then(_ => {
+ InspectorTest.addResult("The iframe loaded.");
+ InspectorTest.addResult("-----------------");
+ InspectorTest.addResult("Loading another iframe.");
+ return InspectorTest.callFunctionInPageAsync(
+ "loadIframe", [ scope + "?RedirectError"]);
+ })
+ .then(_ => {
+ InspectorTest.addResult("The iframe loaded.");
+ InspectorTest.addResult("-----------------");
+ InspectorTest.addResult("Done");
+ InspectorTest.completeTest();
+ });
+}
+
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests the navigation request related events are available in the DevTools</p>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698