Commit e296674a authored by jsbell@chromium.org's avatar jsbell@chromium.org

ServiceWorker: Spec alignment tweaks for Request/Response objects

Request.method should be ByteString (now supported)
Response.status should be assignable
Response.statusText should be assignable
Response.statusText should be ByteString (now supported)

And added tests for assignable properties/invalid ByteStrings.

R=falken@chromium.org,horo@chromium.org

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

git-svn-id: svn://svn.chromium.org/blink/trunk@176148 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 5dded0e3
......@@ -20,4 +20,11 @@ test(function() {
// Note: detailed behavioral tests for HeaderMap are in another test,
// http/tests/serviceworker/headermap.html.
request.url = 'http://localhost/';
assert_equals(request.url, 'http://localhost/', 'Request.url should be writable');
request.method = 'POST';
assert_equals(request.method, 'POST', 'Request.method should be writable');
assert_throws({name: 'TypeError'}, function() { request.method = 'invalid \u0100'; },
'Request.method should throw on invalid ByteString');
}, 'Request in ServiceWorkerGlobalScope');
......@@ -19,4 +19,12 @@ test(function() {
// Note: detailed behavioral tests for HeaderMap are in another test,
// http/tests/serviceworker/headermap.html.
response.status = 123;
response.statusText = 'Sesame Street';
assert_equals(response.status, 123, 'Response.status should be writable');
assert_equals(response.statusText, 'Sesame Street', 'Response.statusText should be writable');
assert_throws({name:'TypeError'}, function() { response.statusText = 'invalid \u0100'; },
'Response.statusText should throw on invalid ByteString');
}, 'Response in ServiceWorkerGlobalScope');
......@@ -10,8 +10,7 @@
Exposed=ServiceWorker
] interface Request {
attribute DOMString url;
// FIXME: Spec uses ByteString for this. We must perform the DOMString -> ByteString conversion manually (crbug.com/347426).
attribute DOMString method;
attribute ByteString method;
readonly attribute DOMString origin;
readonly attribute HeaderMap headers;
......
......@@ -16,6 +16,7 @@ struct RequestInit {
: method("GET")
{
options.get("url", url);
// FIXME: Spec uses ByteString for method. http://crbug.com/347426
options.get("method", method);
options.get("headers", headers);
}
......
......@@ -26,7 +26,11 @@ public:
~Response() { };
unsigned short status() const { return m_status; }
void setStatus(unsigned short value) { m_status = value; }
String statusText() const { return m_statusText; }
void setStatusText(const String& value) { m_statusText = value; }
PassRefPtr<HeaderMap> headers() const;
void populateWebServiceWorkerResponse(blink::WebServiceWorkerResponse&);
......
......@@ -10,11 +10,8 @@
RuntimeEnabled=ServiceWorker,
Exposed=ServiceWorker
] interface Response {
readonly attribute unsigned short status;
// FIXME: Spec uses ByteString for this. We must perform the DOMString -> ByteString conversion manually (crbug.com/347426).
readonly attribute DOMString statusText;
attribute unsigned short status;
attribute ByteString statusText;
readonly attribute HeaderMap headers;
// FIXME: Implement the following:
......
......@@ -17,6 +17,7 @@ struct ResponseInit {
, statusText("OK")
{
options.get("status", status);
// FIXME: Spec uses ByteString for statusText. http://crbug.com/347426
options.get("statusText", statusText);
options.get("headers", headers);
}
......
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