Commit 1c0d2d33 authored by tyoshino@chromium.org's avatar tyoshino@chromium.org

Test that cookies set by document.cookie are sent in a WebSocket handshake.

BUG=none

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

git-svn-id: svn://svn.chromium.org/blink/trunk@175548 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent ee175426
This is a testharness.js-based test.
PASS Cookies set by document.cookie are sent in a WebSocket handshake
Harness: the test ran to completion.
<html>
<body>
<script src="/js-test-resources/testharness.js"></script>
<script src="/js-test-resources/testharnessreport.js"></script>
<script>
var t = async_test('Cookies set by document.cookie are sent in a WebSocket handshake');
t.step(function() {
var cookie_id = 'test_' + Date.now() + '.' + Math.random();
document.cookie = cookie_id + '=1; Path=/echo-cookie';
new Promise(t.step_func(function(resolve, reject) {
var echo_ws = new WebSocket('ws://127.0.0.1:8880/echo-cookie');
echo_ws.onmessage = t.step_func(function (e) {
resolve(e.data);
});
echo_ws.onerror = t.step_func(function () {
reject('Unexpected error event');
});
echo_ws.onclose = t.step_func(function (e) {
reject('Unexpected close event: ' + e);
});
})).then(t.step_func(function(actual) {
var expected = cookie_id + '=1';
assert_equals(actual, expected);
document.cookie = cookie_id + '=1; Path=/echo-cookie; Max-Age=0';
t.done();
}), t.step_func(function(e) {
assert_unreached(e);
}));
});
</script>
</body>
</html>
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