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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html

Issue 1844053003: CREDENTIAL: Rework the integration with Fetch (1/2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: horo@ 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
Index: third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html
index da43aef0a1aa5b74033e428ed43a6f188eb303dc..e62db9e3b4a88376000062df2026845a608d05dd 100644
--- a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html
+++ b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html
@@ -4,25 +4,52 @@
<script src="../resources/testharnessreport.js"></script>
<script src="/serviceworker/resources/interfaces.js"></script>
<script>
-promise_test(function() {
- var credential = new PasswordCredential({
- id: 'id',
- password: 'pencil',
- name: 'name',
- iconURL: 'https://example.com/icon.png'
- });
+var c = new PasswordCredential({
+ id: 'id',
+ password: 'pencil',
+ name: 'name',
+ iconURL: 'https://example.com/icon.png'
+});
+
+promise_test(_ => {
+ var r = new Request('/', { credentials: c, method: 'POST' });
+ var clone = r.clone();
+ assert_equals(r.credentials, "password");
+ assert_equals(clone.credentials, "password");
+ r.text().then(t => assert_equals(t, ""));
+ clone.text().then(t => assert_equals(t, ""));
horo 2016/04/04 08:54:04 You have to return the promise. return clone.text(
Mike West 2016/04/04 10:12:12 Fixed, thank you.
+}, "Creating a 'Request' does not expose the credential.");
+
+promise_test(_ => {
+ assert_throws(new TypeError(), _ => new Request("https://cross-origin.example.test/", { credentials: c, method: 'POST' }));
+ assert_throws(new TypeError(), _ => new Request("/", { credentials: c, method: 'GET' }));
+ assert_throws(new TypeError(), _ => new Request("/", { credentials: c, method: 'HEAD' }));
+ assert_throws(new TypeError(), _ => new Request("/", { credentials: 'password', method: 'POST' }));
+ assert_throws(new TypeError(), _ => new Request("/", { credentials: 'password', method: 'GET' }));
+ assert_throws(new TypeError(), _ => new Request("/", { credentials: 'password', body: "Body", method: 'GET' }));
+}, "Creating a 'Request' throws in various ways.");
- return fetch("./resources/echo-post.php", { body: credential, method: "POST" })
- .then(function (r) {
- return r.json();
- })
- .then(function (j) {
+promise_test(function() {
+ return fetch("./resources/echo-post.php", { credentials: c, method: "POST" })
+ .then(resp => resp.json())
+ .then(j => {
assert_equals(j.username, 'id');
assert_equals(j.password, 'pencil');
});
}, "Simple Fetch");
promise_test(function() {
+ var req = new Request('./resources/echo-post.php', { credentials: c, method: "POST" });
+ var clone = req.clone();
+ fetch(clone)
horo 2016/04/04 08:54:04 return fetch(clone) I don't know why, but this te
Mike West 2016/04/04 10:12:12 I split this into two tests, one with `fetch(new R
+ .then(resp => resp.json())
+ .then(j => {
+ assert_equals(j.username, 'id');
+ assert_equals(j.password, 'pencil');
+ });
+}, "Fetch with cloned Request");
+
+promise_test(function() {
var credential = new PasswordCredential({
id: 'id',
password: 'pencil',
@@ -33,7 +60,7 @@ promise_test(function() {
credential.idName = "notUsername";
credential.passwordName = "notPassword";
- return fetch("./resources/echo-post.php", { body: credential, method: "POST" })
+ return fetch("./resources/echo-post.php", { credentials: credential, method: "POST" })
.then(function (r) {
return r.json()
})
@@ -56,7 +83,7 @@ promise_test(function() {
var fd = new FormData();
credential.additionalData = fd;
- return fetch("./resources/echo-post.php", { body: credential, method: "POST" })
+ return fetch("./resources/echo-post.php", { credentials: credential, method: "POST" })
.then(function (r) {
return r.json();
})
@@ -79,7 +106,7 @@ promise_test(function() {
fd.append("csrf", "[randomness]");
credential.additionalData = fd;
- return fetch("./resources/echo-post.php", { body: credential, method: "POST" })
+ return fetch("./resources/echo-post.php", { credentials: credential, method: "POST" })
.then(function (r) {
return r.json();
})
@@ -106,7 +133,7 @@ promise_test(function() {
// Use post-echo.cgi since PHP doesn't give us the raw data of a POST's
// body if it's multipart/form-data.
- return fetch("/xmlhttprequest/resources/post-echo.cgi", { body: credential, method: "POST" })
+ return fetch("/xmlhttprequest/resources/post-echo.cgi", { credentials: credential, method: "POST" })
.then(function (r) {
return r.text();
})
@@ -133,7 +160,7 @@ promise_test(function() {
var params = new URLSearchParams();
credential.additionalData = params;
- return fetch("./resources/echo-post.php", { body: credential, method: "POST" })
+ return fetch("./resources/echo-post.php", { credentials: credential, method: "POST" })
.then(function (r) {
return r.json();
})
@@ -156,7 +183,7 @@ promise_test(function() {
params.append("csrf", "[randomness]");
credential.additionalData = params;
- return fetch("./resources/echo-post.php", { body: credential, method: "POST" })
+ return fetch("./resources/echo-post.php", { credentials: credential, method: "POST" })
.then(function (r) {
return r.json();
})
@@ -181,7 +208,7 @@ promise_test(function() {
params.append("password", "bar");
credential.additionalData = params;
- return fetch("./resources/echo-raw-post.php", { body: credential, method: "POST" })
+ return fetch("./resources/echo-raw-post.php", { credentials: credential, method: "POST" })
.then(function (r) {
return r.text();
})
@@ -204,7 +231,7 @@ promise_test(function() {
params.append("a", "3");
credential.additionalData = params;
- return fetch("./resources/echo-raw-post.php", { body: credential, method: "POST" })
+ return fetch("./resources/echo-raw-post.php", { credentials: credential, method: "POST" })
.then(function (r) {
return r.text();
})

Powered by Google App Engine
This is Rietveld 408576698