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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 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/imported/wpt/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-request-xhr-iframe.html b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html
similarity index 57%
copy from third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-request-xhr-iframe.html
copy to third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html
index 609ac6e433a88b35191f40879e3eddad4a4fc429..26c6b7344677a9a6792db342b108d2bbc68d3ec7 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-request-xhr-iframe.html
+++ b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html
@@ -1,9 +1,13 @@
-<script src="../../resources/testharness.js"></script>
-<script src="../../resources/get-host-info.js?pipe=sub"></script>
-<script src="test-helpers.js"></script>
+<script src="../resources/get-host-info.sub.js"></script>
+<script src="test-helpers.sub.js?pipe=sub"></script>
<script>
+var port;
var host_info = get_host_info();
+function assert_equals(a, b) {
+ port.postMessage({results: 'equals', got: a, expected: b});
+}
+
function get_boundary(headers) {
var reg = new RegExp('multipart\/form-data; boundary=(.*)');
for (var i = 0; i < headers.length; ++i) {
@@ -55,61 +59,8 @@ function xhr_send(url_base, method, data, with_credentials) {
});
}
-function get_sorted_header_name_list(headers) {
- const header_names = [];
- for (const [name, value] of headers) {
- header_names.push(name);
- }
- header_names.sort();
- return header_names;
-}
-
-function get_header_test() {
- return xhr_send(host_info['HTTP_ORIGIN'], 'GET', '', false)
- .then(function(response) {
- assert_array_equals(
- get_sorted_header_name_list(response.headers),
- ["accept", "user-agent"],
- 'event.request has the expected headers for same-origin GET.');
- });
-}
-
-// TODO(tyoshino): Fix the stack not to include the Origin header as specified
-// in the spec.
-function post_header_test() {
- return xhr_send(host_info['HTTP_ORIGIN'], 'POST', '', false)
- .then(function(response) {
- assert_array_equals(
- get_sorted_header_name_list(response.headers),
- ["accept", "content-type", "origin", "user-agent"],
- 'event.request has the expected headers for same-origin POST.');
- });
-}
-
-function cross_origin_get_header_test() {
- return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'GET', '', false)
- .then(function(response) {
- assert_array_equals(
- get_sorted_header_name_list(response.headers),
- ["accept", "user-agent"],
- 'event.request has the expected headers for cross-origin GET.');
- });
-}
-
-// TODO(tyoshino): Fix the stack not to include the Origin header as specified
-// in the spec.
-function cross_origin_post_header_test() {
- return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'POST', '', false)
- .then(function(response) {
- assert_array_equals(
- get_sorted_header_name_list(response.headers),
- ["accept", "content-type", "origin", "user-agent"],
- 'event.request has the expected headers for cross-origin POST.');
- });
-}
-
function string_test() {
- return xhr_send(host_info['HTTP_ORIGIN'], 'POST', 'test string', false)
+ return xhr_send(host_info['HTTPS_ORIGIN'], 'POST', 'test string', false)
.then(function(response) {
assert_equals(response.method, 'POST');
assert_equals(response.body, 'test string');
@@ -117,7 +68,7 @@ function string_test() {
}
function blob_test() {
- return xhr_send(host_info['HTTP_ORIGIN'], 'POST', new Blob(['test blob']),
+ return xhr_send(host_info['HTTPS_ORIGIN'], 'POST', new Blob(['test blob']),
false)
.then(function(response) {
assert_equals(response.method, 'POST');
@@ -126,7 +77,7 @@ function blob_test() {
}
function custom_method_test() {
- return xhr_send(host_info['HTTP_ORIGIN'], 'XXX', 'test string xxx', false)
+ return xhr_send(host_info['HTTPS_ORIGIN'], 'XXX', 'test string xxx', false)
.then(function(response) {
assert_equals(response.method, 'XXX');
assert_equals(response.body, 'test string xxx');
@@ -134,7 +85,7 @@ function custom_method_test() {
}
function options_method_test() {
- return xhr_send(host_info['HTTP_ORIGIN'], 'OPTIONS', 'test string xxx', false)
+ return xhr_send(host_info['HTTPS_ORIGIN'], 'OPTIONS', 'test string xxx', false)
.then(function(response) {
assert_equals(response.method, 'OPTIONS');
assert_equals(response.body, 'test string xxx');
@@ -142,15 +93,11 @@ function options_method_test() {
}
function form_data_test() {
- return create_file_system_file('fsfile.txt', 'fs file content')
- .then(function(file_system_file) {
- var formData = new FormData();
- formData.append('sample string', '1234567890');
- formData.append('sample blob', new Blob(['blob content']));
- formData.append('sample file', new File(['file content'], 'file.dat'));
- formData.append('sample fs file', file_system_file);
- return xhr_send(host_info['HTTP_ORIGIN'], 'POST', formData, false);
- })
+ var formData = new FormData();
+ formData.append('sample string', '1234567890');
+ formData.append('sample blob', new Blob(['blob content']));
+ formData.append('sample file', new File(['file content'], 'file.dat'));
+ return xhr_send(host_info['HTTPS_ORIGIN'], 'POST', formData, false)
.then(function(response) {
assert_equals(response.method, 'POST');
var boundary = get_boundary(response.headers);
@@ -171,33 +118,27 @@ function form_data_test() {
'Content-Type: application/octet-stream\r\n' +
'\r\n' +
'file content\r\n' +
- '--' + boundary + '\r\n' +
- 'Content-Disposition: form-data; name="sample fs file"; ' +
- 'filename="fsfile.txt"\r\n' +
- 'Content-Type: text/plain\r\n' +
- '\r\n' +
- 'fs file content\r\n' +
'--' + boundary + '--\r\n';
assert_equals(response.body, expected_body);
});
}
function mode_credentials_test() {
- return xhr_send(host_info['HTTP_ORIGIN'], 'GET', '', false)
+ return xhr_send(host_info['HTTPS_ORIGIN'], 'GET', '', false)
.then(function(response){
assert_equals(response.mode, 'cors');
- assert_equals(response.credentials, 'include');
- return xhr_send(host_info['HTTP_ORIGIN'], 'GET', '', true);
+ assert_equals(response.credentials, 'same-origin');
+ return xhr_send(host_info['HTTPS_ORIGIN'], 'GET', '', true);
})
.then(function(response){
assert_equals(response.mode, 'cors');
assert_equals(response.credentials, 'include');
- return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'GET', '', false);
+ return xhr_send(host_info['HTTPS_REMOTE_ORIGIN'], 'GET', '', false);
})
.then(function(response){
assert_equals(response.mode, 'cors');
assert_equals(response.credentials, 'same-origin');
- return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'GET', '', true);
+ return xhr_send(host_info['HTTPS_REMOTE_ORIGIN'], 'GET', '', true);
})
.then(function(response){
assert_equals(response.mode, 'cors');
@@ -224,12 +165,8 @@ function data_url_test() {
}
window.addEventListener('message', function(evt) {
- var port = evt.ports[0];
- get_header_test()
- .then(post_header_test)
- .then(cross_origin_get_header_test)
- .then(cross_origin_post_header_test)
- .then(string_test)
+ port = evt.ports[0];
+ string_test()
.then(blob_test)
.then(custom_method_test)
.then(options_method_test)

Powered by Google App Engine
This is Rietveld 408576698