Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a29cf74aaea44969dd4456c93c7519ffad022896 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html |
| @@ -0,0 +1,162 @@ |
| +<!DOCTYPE html> |
| +<title>Credential Manager: PasswordCredential basics.</title> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="/serviceworker/resources/interfaces.js"></script> |
| +<script> |
| +promise_test(function(t) { |
| + var credential = new PasswordCredential({ |
| + id: 'id', |
| + password: 'pencil', |
| + name: 'name', |
| + iconURL: 'https://example.com/icon.png' |
| + }); |
| + |
| + return fetch("./resources/echo-post.php", { body: credential, method: "POST" }) |
| + .then(function (r) { |
| + return r.json(); |
| + }) |
| + .then(function (j) { |
| + assert_equals(j.username, 'id'); |
| + assert_equals(j.password, 'pencil'); |
| + }); |
| +}, "Simple Fetch"); |
| + |
| +promise_test(function(t) { |
| + var credential = new PasswordCredential({ |
| + id: 'id', |
| + password: 'pencil', |
| + name: 'name', |
| + iconURL: 'https://example.com/icon.png' |
| + }); |
| + |
| + credential.idName = "notUsername"; |
| + credential.passwordName = "notPassword"; |
| + |
| + return fetch("./resources/echo-post.php", { body: credential, method: "POST" }) |
| + .then(function (r) { |
| + return r.json() |
| + }) |
| + .then(function (j) { |
| + assert_equals(j.username, undefined); |
| + assert_equals(j.password, undefined); |
| + assert_equals(j.notUsername, 'id'); |
| + assert_equals(j.notPassword, 'pencil'); |
| + }); |
| +}, "'idName' and 'passwordName'"); |
| + |
| +promise_test(function(t) { |
| + var credential = new PasswordCredential({ |
| + id: 'id', |
| + password: 'pencil', |
| + name: 'name', |
| + iconURL: 'https://example.com/icon.png' |
| + }); |
| + |
| + var fd = new FormData(); |
| + credential.additionalData = fd; |
| + |
| + return fetch("./resources/echo-post.php", { body: credential, method: "POST" }) |
| + .then(function (r) { |
| + return r.json(); |
| + }) |
| + .then(function (j) { |
| + assert_equals(j.username, 'id'); |
| + assert_equals(j.password, 'pencil'); |
| + }); |
| +}, "'additionalData': Empty FormData has no effect."); |
| + |
| +promise_test(function(t) { |
| + var credential = new PasswordCredential({ |
| + id: 'id', |
| + password: 'pencil', |
| + name: 'name', |
| + iconURL: 'https://example.com/icon.png' |
| + }); |
| + |
| + var fd = new FormData(); |
| + fd.append("excitingData", "exciting value"); |
| + fd.append("csrf", "[randomness]"); |
| + credential.additionalData = fd; |
| + |
| + return fetch("./resources/echo-post.php", { body: credential, method: "POST" }) |
| + .then(function (r) { |
| + return r.json(); |
| + }) |
| + then(function (j) { |
| + assert_equals(j.username, 'id'); |
| + assert_equals(j.password, 'pencil'); |
| + assert_equals(j.excitingData, 'exciting value'); |
| + assert_equals(j.csrf, '[randomness]'); |
| + }); |
| +}, "'additionalData': FormData properties are properly injected."); |
| + |
| +promise_test(function(t) { |
| + var credential = new PasswordCredential({ |
| + id: 'id', |
| + password: 'pencil', |
| + name: 'name', |
| + iconURL: 'https://example.com/icon.png' |
| + }); |
| + |
| + var params = new URLSearchParams(); |
| + credential.additionalData = params; |
| + |
| + return fetch("./resources/echo-post.php", { body: credential, method: "POST" }) |
| + .then(function (r) { |
| + return r.json(); |
| + }) |
| + .then(function (j) { |
| + assert_equals(j.username, 'id'); |
| + assert_equals(j.password, 'pencil'); |
| + }); |
| +}, "'additionalData': Empty URLSearchParams has no effect."); |
| + |
| +promise_test(function(t) { |
| + var credential = new PasswordCredential({ |
| + id: 'id', |
| + password: 'pencil', |
| + name: 'name', |
| + iconURL: 'https://example.com/icon.png' |
| + }); |
| + |
| + var params = new URLSearchParams(); |
| + params.append("excitingData", "exciting value"); |
| + params.append("csrf", "[randomness]"); |
| + credential.additionalData = params; |
| + |
| + return fetch("./resources/echo-post.php", { body: credential, method: "POST" }) |
| + .then(function (r) { |
| + return r.json(); |
| + }) |
| + .then(function (j) { |
| + assert_equals(j.username, 'id'); |
| + assert_equals(j.password, 'pencil'); |
| + assert_equals(j.excitingData, 'exciting value'); |
| + assert_equals(j.csrf, '[randomness]'); |
| + }); |
| +}, "'additionalData': URLSearchParams properties are properly injected."); |
| + |
| +promise_test(function(t) { |
| + var credential = new PasswordCredential({ |
| + id: 'id', |
| + password: 'pencil', |
| + name: 'name', |
| + iconURL: 'https://example.com/icon.png' |
| + }); |
| + |
| + var params = new URLSearchParams(); |
| + params.append("a", "1"); |
| + params.append("a", "2"); |
| + params.append("a", "3"); |
| + credential.additionalData = params; |
| + |
| + return fetch("./resources/echo-raw-post.php", { body: credential, method: "POST" }) |
| + .then(function (r) { |
| + return r.text(); |
| + }) |
| + .then(function (t) { |
|
philipj_slow
2015/11/18 10:00:05
Maybe expand this to text since t is also the test
|
| + assert_equals(t, 'a=1&a=2&a=3&username=id&password=pencil'); |
| + }); |
| +}, "'additionalData': URLSearchParams properties are properly injected (ordering matters)."); |
| +</script> |