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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/testserver.js

Issue 1894183003: Edge case cors preflight race condition (DON'T SUBMIT). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/weird-cors-test-case.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/testserver.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/testserver.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/testserver.js
new file mode 100644
index 0000000000000000000000000000000000000000..2c95642672417707e54512538f53711abff6a67b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/testserver.js
@@ -0,0 +1,37 @@
+//Lets require/import the HTTP module
+var http = require('http');
+
+//Lets define a port we want to listen to
+const PORT=8888;
+
+var finish_response = function() {};
+
+//We need a function which handles requests and send response
+function handleRequest(request, response) {
+ console.log('URL: "' + request.url + '", method: ' + request.method);
+ if (request.url == '/cors-request') {
+ if (request.method == 'OPTIONS') {
+ finish_response = function() {
+ response.setHeader('Access-Control-Allow-Origin', '*');
+ response.setHeader('Access-Control-Allow-Methods', 'GET, PUT');
+ response.end();
+ }
+ } else {
+ response.setHeader('Access-Control-Allow-Origin', '*');
+ response.end('cors');
+ }
+ } else if (request.url == '/release') {
+ finish_response();
+ finish_response = function() {};
+ response.end('Released!');
+ }
+}
+
+//Create a server
+var server = http.createServer(handleRequest);
+
+//Lets start our server
+server.listen(PORT, function(){
+ //Callback triggered when server is successfully listening. Hurray!
+ console.log("Server listening on: http://localhost:%s", PORT);
+});
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/weird-cors-test-case.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698