| 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..911ecadb462952626daa00fcb39d174662103720
|
| --- /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() {
|
| + 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() {
|
| + 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() {
|
| + 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() {
|
| + 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() {
|
| + 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() {
|
| + 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() {
|
| + 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) {
|
| + assert_equals(t, 'a=1&a=2&a=3&username=id&password=pencil');
|
| + });
|
| +}, "'additionalData': URLSearchParams properties are properly injected (ordering matters).");
|
| +</script>
|
|
|