mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Test for bug 1214752 - verify that the network monitor shows CORS preflights properly. r=Honza
This commit is contained in:
parent
fd24253b3a
commit
2ac0894877
@ -6,6 +6,7 @@ support-files =
|
||||
head.js
|
||||
html_content-type-test-page.html
|
||||
html_content-type-without-cache-test-page.html
|
||||
html_cors-test-page.html
|
||||
html_custom-get-page.html
|
||||
html_single-get-page.html
|
||||
html_cyrillic-test-page.html
|
||||
@ -73,6 +74,7 @@ subsuite = clipboard
|
||||
[browser_net_copy_as_curl.js]
|
||||
subsuite = clipboard
|
||||
skip-if = e10s # Bug 1091596
|
||||
[browser_net_cors_requests.js]
|
||||
[browser_net_cyrillic-01.js]
|
||||
[browser_net_cyrillic-02.js]
|
||||
[browser_net_details-no-duplicated-content.js]
|
||||
|
29
devtools/client/netmonitor/test/browser_net_cors_requests.js
Normal file
29
devtools/client/netmonitor/test/browser_net_cors_requests.js
Normal file
@ -0,0 +1,29 @@
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Test that CORS preflight requests are displayed by network monitor
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
let [, debuggee, monitor] = yield initNetMonitor(CORS_URL);
|
||||
let { RequestsMenu } = monitor.panelWin.NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
info("Performing a CORS request");
|
||||
let url = "http://test1.example.com" + CORS_SJS_PATH;
|
||||
debuggee.performRequests(url, "triggering/preflight", "post-data");
|
||||
|
||||
info("Waiting until the requests appear in netmonitor");
|
||||
yield waitForNetworkEvents(monitor, 1, 1);
|
||||
|
||||
info("Checking the preflight and flight methods");
|
||||
["OPTIONS", "POST"].forEach((method, i) => {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i), method, url);
|
||||
});
|
||||
|
||||
yield teardown(monitor);
|
||||
finish();
|
||||
});
|
@ -42,6 +42,7 @@ const STATISTICS_URL = EXAMPLE_URL + "html_statistics-test-page.html";
|
||||
const CURL_URL = EXAMPLE_URL + "html_copy-as-curl.html";
|
||||
const CURL_UTILS_URL = EXAMPLE_URL + "html_curl-utils.html";
|
||||
const SEND_BEACON_URL = EXAMPLE_URL + "html_send-beacon.html";
|
||||
const CORS_URL = EXAMPLE_URL + "html_cors-test-page.html";
|
||||
|
||||
const SIMPLE_SJS = EXAMPLE_URL + "sjs_simple-test-server.sjs";
|
||||
const CONTENT_TYPE_SJS = EXAMPLE_URL + "sjs_content-type-test-server.sjs";
|
||||
|
31
devtools/client/netmonitor/test/html_cors-test-page.html
Normal file
31
devtools/client/netmonitor/test/html_cors-test-page.html
Normal file
@ -0,0 +1,31 @@
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>POST with CORS test page</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
function post(url, contentType, postData) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", url, true);
|
||||
xhr.setRequestHeader("Content-Type", contentType);
|
||||
xhr.send(postData);
|
||||
}
|
||||
|
||||
function performRequests(url, contentType, postData) {
|
||||
post(url, contentType, postData);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -9,6 +9,7 @@ function handleRequest(request, response) {
|
||||
response.setHeader("Expires", "0");
|
||||
|
||||
response.setHeader("Access-Control-Allow-Origin", "*", false);
|
||||
response.setHeader("Access-Control-Allow-Headers", "content-type", false);
|
||||
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8", false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user