Commit d584b5d6 authored by horo@chromium.org's avatar horo@chromium.org

[ServiceWorker] Use the cookie which is differnt from the username in LayoutTest.

Currently we use the cookie name which is same as the username.
But I will add tests which change the username.
For the preparation of them, this patch changes LayoutTest to use the cookie which is differnt from the username.

BUG=N/A
TEST=http/tests/serviceworker

Review URL: https://codereview.chromium.org/722603002

git-svn-id: svn://svn.chromium.org/blink/trunk@185265 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3e915b3e
...@@ -7,9 +7,11 @@ ...@@ -7,9 +7,11 @@
<script> <script>
async_test(function(t) { async_test(function(t) {
var login1 = var login1 =
test_login(t, 'http://127.0.0.1:8000', 'username1', 'password1'); test_login(t, 'http://127.0.0.1:8000',
'username1', 'password1', 'cookie1');
var login2 = var login2 =
test_login(t, 'http://localhost:8000', 'username2', 'password2'); test_login(t, 'http://localhost:8000',
'username2', 'password2', 'cookie2');
var SCOPE = 'resources/fetch-canvas-tainting-iframe.html'; var SCOPE = 'resources/fetch-canvas-tainting-iframe.html';
var SCRIPT = 'resources/fetch-rewrite-worker.js'; var SCRIPT = 'resources/fetch-rewrite-worker.js';
var host_info = get_host_info(); var host_info = get_host_info();
......
...@@ -7,9 +7,11 @@ ...@@ -7,9 +7,11 @@
<script> <script>
async_test(function(t) { async_test(function(t) {
var login1 = var login1 =
test_login(t, 'http://127.0.0.1:8000', 'username1', 'password1'); test_login(t, 'http://127.0.0.1:8000',
'username1', 'password1', 'cookie1');
var login2 = var login2 =
test_login(t, 'http://localhost:8000', 'username2', 'password2'); test_login(t, 'http://localhost:8000',
'username2', 'password2', 'cookie2');
var SCOPE = 'resources/fetch-cors-xhr-iframe.html'; var SCOPE = 'resources/fetch-cors-xhr-iframe.html';
var SCRIPT = 'resources/fetch-rewrite-worker.js'; var SCRIPT = 'resources/fetch-rewrite-worker.js';
var host_info = get_host_info(); var host_info = get_host_info();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Set authentication info // Set authentication info
window.addEventListener("message", function(evt) { window.addEventListener("message", function(evt) {
var port = evt.ports[0]; var port = evt.ports[0];
document.cookie = 'cookie=' + evt.data.username; document.cookie = 'cookie=' + evt.data.cookie;
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.addEventListener('load', function() { xhr.addEventListener('load', function() {
port.postMessage({msg: 'LOGIN FINISHED'}); port.postMessage({msg: 'LOGIN FINISHED'});
......
...@@ -85,7 +85,7 @@ var checkJsonpMethod = function(method, url, data) { ...@@ -85,7 +85,7 @@ var checkJsonpMethod = function(method, url, data) {
method, method,
'Method must match url:' + url); 'Method must match url:' + url);
}; };
var checkJsonpAuth = function(username, password, url, data) { var checkJsonpAuth = function(username, password, cookie, url, data) {
assert_equals(data.jsonpResult, assert_equals(data.jsonpResult,
'success', 'success',
url + ' jsonpResult must be success'); url + ' jsonpResult must be success');
...@@ -96,7 +96,7 @@ var checkJsonpAuth = function(username, password, url, data) { ...@@ -96,7 +96,7 @@ var checkJsonpAuth = function(username, password, url, data) {
password, password,
'Password must match. url: ' + url); 'Password must match. url: ' + url);
assert_equals(data.cookie, assert_equals(data.cookie,
username, cookie,
'Cookie must match. url: ' + url); 'Cookie must match. url: ' + url);
}; };
var checkJsonpError = checkJsonpResult.bind(this, 'error'); var checkJsonpError = checkJsonpResult.bind(this, 'error');
...@@ -109,16 +109,19 @@ var methodIsGET = checkJsonpMethod.bind(this, 'GET'); ...@@ -109,16 +109,19 @@ var methodIsGET = checkJsonpMethod.bind(this, 'GET');
var methodIsPOST = checkJsonpMethod.bind(this, 'POST'); var methodIsPOST = checkJsonpMethod.bind(this, 'POST');
var methodIsPUT = checkJsonpMethod.bind(this, 'PUT'); var methodIsPUT = checkJsonpMethod.bind(this, 'PUT');
var methodIsXXX = checkJsonpMethod.bind(this, 'XXX'); var methodIsXXX = checkJsonpMethod.bind(this, 'XXX');
var authCheckNone = checkJsonpAuth.bind(this, 'undefined', 'undefined'); var authCheckNone =
var authCheck1 = checkJsonpAuth.bind(this, 'username1', 'password1'); checkJsonpAuth.bind(this, 'undefined', 'undefined', 'undefined');
var authCheck2 = checkJsonpAuth.bind(this, 'username2', 'password2'); var authCheck1 = checkJsonpAuth.bind(this, 'username1', 'password1', 'cookie1');
var authCheck2 = checkJsonpAuth.bind(this, 'username2', 'password2', 'cookie2');
function executeTests(test, test_targets) { function executeTests(test, test_targets) {
test.step(function() { test.step(function() {
var login1 = var login1 =
test_login(test, 'http://127.0.0.1:8000', 'username1', 'password1'); test_login(test, 'http://127.0.0.1:8000',
'username1', 'password1', 'cookie1');
var login2 = var login2 =
test_login(test, 'http://localhost:8000', 'username2', 'password2'); test_login(test, 'http://localhost:8000',
'username2', 'password2', 'cookie2');
var workerScript = 'resources/fetch-access-control-worker.js'; var workerScript = 'resources/fetch-access-control-worker.js';
var worker = undefined; var worker = undefined;
var frameWindow = {}; var frameWindow = {};
......
...@@ -247,7 +247,7 @@ function base_path() { ...@@ -247,7 +247,7 @@ function base_path() {
return location.pathname.replace(/\/[^\/]*$/, '/'); return location.pathname.replace(/\/[^\/]*$/, '/');
} }
function test_login(test, origin, username, password) { function test_login(test, origin, username, password, cookie) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
with_iframe( with_iframe(
origin + base_path() + origin + base_path() +
...@@ -259,7 +259,7 @@ function test_login(test, origin, username, password) { ...@@ -259,7 +259,7 @@ function test_login(test, origin, username, password) {
resolve(); resolve();
}); });
frame.contentWindow.postMessage( frame.contentWindow.postMessage(
{username: username, password: password}, {username: username, password: password, cookie: cookie},
[channel.port2], origin); [channel.port2], origin);
})); }));
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment