Diff
Modified: trunk/LayoutTests/ChangeLog (239225 => 239226)
--- trunk/LayoutTests/ChangeLog 2018-12-14 20:06:38 UTC (rev 239225)
+++ trunk/LayoutTests/ChangeLog 2018-12-14 20:41:31 UTC (rev 239226)
@@ -1,3 +1,14 @@
+2018-12-14 Matt Baker <[email protected]>
+
+ Web Inspector: Cookies view should use model objects instead of raw payload data
+ https://bugs.webkit.org/show_bug.cgi?id=189533
+ <rdar://problem/44364183>
+
+ Reviewed by Joseph Pecoraro and Devin Rousso.
+
+ * inspector/unit-tests/cookie-expected.txt:
+ * inspector/unit-tests/cookie.html:
+
2018-12-14 Simon Fraser <[email protected]>
REGRESSION (r233268): contents of an animated element inside overflow:hidden disappear
Modified: trunk/LayoutTests/inspector/unit-tests/cookie-expected.txt (239225 => 239226)
--- trunk/LayoutTests/inspector/unit-tests/cookie-expected.txt 2018-12-14 20:06:38 UTC (rev 239225)
+++ trunk/LayoutTests/inspector/unit-tests/cookie-expected.txt 2018-12-14 20:41:31 UTC (rev 239226)
@@ -44,7 +44,7 @@
PASS: Empty header should produce null.
HEADER: Set-Cookie: name=value
PASS: Value should be a WI.Cookie.
-PASS: cookie.rawHeader should be the original header text.
+PASS: cookie.header should be the original header text.
PASS: cookie.type should be WI.Cookie.Type.Response.
PASS: cookie.name should be 'name'.
PASS: cookie.value should be 'value'.
@@ -57,7 +57,7 @@
HEADER: Set-Cookie: name=value; path=/foo
PASS: Value should be a WI.Cookie.
-PASS: cookie.rawHeader should be the original header text.
+PASS: cookie.header should be the original header text.
PASS: cookie.type should be WI.Cookie.Type.Response.
PASS: cookie.name should be 'name'.
PASS: cookie.value should be 'value'.
@@ -70,7 +70,7 @@
HEADER: Set-Cookie: name=value; domain=example.com
PASS: Value should be a WI.Cookie.
-PASS: cookie.rawHeader should be the original header text.
+PASS: cookie.header should be the original header text.
PASS: cookie.type should be WI.Cookie.Type.Response.
PASS: cookie.name should be 'name'.
PASS: cookie.value should be 'value'.
@@ -83,7 +83,7 @@
HEADER: Set-Cookie: name=value; secure
PASS: Value should be a WI.Cookie.
-PASS: cookie.rawHeader should be the original header text.
+PASS: cookie.header should be the original header text.
PASS: cookie.type should be WI.Cookie.Type.Response.
PASS: cookie.name should be 'name'.
PASS: cookie.value should be 'value'.
@@ -96,7 +96,7 @@
HEADER: Set-Cookie: name=value; Secure
PASS: Value should be a WI.Cookie.
-PASS: cookie.rawHeader should be the original header text.
+PASS: cookie.header should be the original header text.
PASS: cookie.type should be WI.Cookie.Type.Response.
PASS: cookie.name should be 'name'.
PASS: cookie.value should be 'value'.
@@ -109,7 +109,7 @@
HEADER: Set-Cookie: name=value; HttpOnly
PASS: Value should be a WI.Cookie.
-PASS: cookie.rawHeader should be the original header text.
+PASS: cookie.header should be the original header text.
PASS: cookie.type should be WI.Cookie.Type.Response.
PASS: cookie.name should be 'name'.
PASS: cookie.value should be 'value'.
@@ -122,7 +122,7 @@
HEADER: Set-Cookie: name=value; expires=Fri 06-Oct-2017 03:20:27 GMT; Max-Age=3600
PASS: Value should be a WI.Cookie.
-PASS: cookie.rawHeader should be the original header text.
+PASS: cookie.header should be the original header text.
PASS: cookie.type should be WI.Cookie.Type.Response.
PASS: cookie.name should be 'name'.
PASS: cookie.value should be 'value'.
@@ -135,7 +135,7 @@
HEADER: Set-Cookie: name=value; expires=Fri 06-Oct-2017 03:43:47 GMT; Max-Age=5000; path=/foo; domain=example.com; secure; HttpOnly
PASS: Value should be a WI.Cookie.
-PASS: cookie.rawHeader should be the original header text.
+PASS: cookie.header should be the original header text.
PASS: cookie.type should be WI.Cookie.Type.Response.
PASS: cookie.name should be 'name'.
PASS: cookie.value should be 'value'.
@@ -149,7 +149,7 @@
HEADER: Set-Cookie: name=value; Unknown; path=/one/two
WARN: Unknown Cookie attribute: Unknown
PASS: Value should be a WI.Cookie.
-PASS: cookie.rawHeader should be the original header text.
+PASS: cookie.header should be the original header text.
PASS: cookie.type should be WI.Cookie.Type.Response.
PASS: cookie.name should be 'name'.
PASS: cookie.value should be 'value'.
@@ -163,7 +163,7 @@
HEADER: Set-Cookie: name=value; Unknown=Ignored; path=/one/two
WARN: Unknown Cookie attribute: Unknown=Ignored
PASS: Value should be a WI.Cookie.
-PASS: cookie.rawHeader should be the original header text.
+PASS: cookie.header should be the original header text.
PASS: cookie.type should be WI.Cookie.Type.Response.
PASS: cookie.name should be 'name'.
PASS: cookie.value should be 'value'.
@@ -176,7 +176,7 @@
HEADER: Set-Cookie: name=somewhat longer value than normal with spaces, and commas; domain=other.example.com
PASS: Value should be a WI.Cookie.
-PASS: cookie.rawHeader should be the original header text.
+PASS: cookie.header should be the original header text.
PASS: cookie.type should be WI.Cookie.Type.Response.
PASS: cookie.name should be 'name'.
PASS: cookie.value should be 'somewhat longer value than normal with spaces, and commas'.
@@ -189,7 +189,7 @@
HEADER: Set-Cookie: name==value=;Domain=.example.com;Expires=Wed, 04-Apr-2018 03:34:02 GMT
PASS: Value should be a WI.Cookie.
-PASS: cookie.rawHeader should be the original header text.
+PASS: cookie.header should be the original header text.
PASS: cookie.type should be WI.Cookie.Type.Response.
PASS: cookie.name should be 'name'.
PASS: cookie.value should be '=value='.
@@ -201,3 +201,8 @@
PASS: cookie.httpOnly should be 'false'.
+-- Running test case: WI.Cookie.url
+PASS: Cookie url should include domain.
+PASS: Cookie url should include domain and path.
+PASS: Secure cookie url should begin with 'https'.
+
Modified: trunk/LayoutTests/inspector/unit-tests/cookie.html (239225 => 239226)
--- trunk/LayoutTests/inspector/unit-tests/cookie.html 2018-12-14 20:06:38 UTC (rev 239225)
+++ trunk/LayoutTests/inspector/unit-tests/cookie.html 2018-12-14 20:41:31 UTC (rev 239226)
@@ -55,7 +55,7 @@
InspectorTest.log(`HEADER: Set-Cookie: ${header}`);
let cookie = WI.Cookie.parseSetCookieResponseHeader(header);
InspectorTest.expectThat(cookie instanceof WI.Cookie, `Value should be a WI.Cookie.`);
- InspectorTest.expectEqual(cookie.rawHeader, header, `cookie.rawHeader should be the original header text.`);
+ InspectorTest.expectEqual(cookie.header, header, `cookie.header should be the original header text.`);
InspectorTest.expectEqual(cookie.type, WI.Cookie.Type.Response, `cookie.type should be WI.Cookie.Type.Response.`);
InspectorTest.expectEqual(cookie.name, expected.name, `cookie.name should be '${expected.name}'.`);
InspectorTest.expectEqual(cookie.value, expected.value, `cookie.value should be '${expected.value}'.`);
@@ -210,6 +210,23 @@
}
});
+ suite.addTestCase({
+ name: "WI.Cookie.url",
+ description: "Cookie url property.",
+ test() {
+ let cookieWithDomain = WI.Cookie.parseSetCookieResponseHeader(`name=value; domain=example.com`);
+ InspectorTest.expectEqual(cookieWithDomain.url, "http://example.com", "Cookie url should include domain.");
+
+ let cookieWithDomainAndPath = WI.Cookie.parseSetCookieResponseHeader(`name=value; domain=example.com; path=/foo`);
+ InspectorTest.expectEqual(cookieWithDomainAndPath.url, "http://example.com/foo", "Cookie url should include domain and path.");
+
+ let secureCookie = WI.Cookie.parseSetCookieResponseHeader(`name=value; domain=example.com; secure`);
+ InspectorTest.expectEqual(secureCookie.url, "https://example.com", "Secure cookie url should begin with 'https'.");
+
+ return true;
+ }
+ });
+
suite.runTestCasesAndFinish();
}
</script>
Modified: trunk/Source/WebInspectorUI/ChangeLog (239225 => 239226)
--- trunk/Source/WebInspectorUI/ChangeLog 2018-12-14 20:06:38 UTC (rev 239225)
+++ trunk/Source/WebInspectorUI/ChangeLog 2018-12-14 20:41:31 UTC (rev 239226)
@@ -1,3 +1,37 @@
+2018-12-14 Matt Baker <[email protected]>
+
+ Web Inspector: Cookies view should use model objects instead of raw payload data
+ https://bugs.webkit.org/show_bug.cgi?id=189533
+ <rdar://problem/44364183>
+
+ Reviewed by Joseph Pecoraro and Devin Rousso.
+
+ * UserInterface/Models/Cookie.js:
+ (WI.Cookie):
+ (WI.Cookie.fromPayload):
+ (WI.Cookie.parseSetCookieResponseHeader):
+ (WI.Cookie.prototype.get type):
+ (WI.Cookie.prototype.get name):
+ (WI.Cookie.prototype.get value):
+ (WI.Cookie.prototype.get header):
+ (WI.Cookie.prototype.get expires):
+ (WI.Cookie.prototype.get maxAge):
+ (WI.Cookie.prototype.get path):
+ (WI.Cookie.prototype.get domain):
+ (WI.Cookie.prototype.get secure):
+ (WI.Cookie.prototype.get httpOnly):
+ (WI.Cookie.prototype.get sameSite):
+ (WI.Cookie.prototype.get size):
+ (WI.Cookie.prototype.get url):
+ (WI.Cookie.prototype.expirationDate):
+ Cleanup Cookie object; add pubic getters for data, `url` property,
+ static `fromPayload` method, and calculate `_size` if missing.
+
+ * UserInterface/Views/CookieStorageContentView.js:
+ (WI.CookieStorageContentView.prototype.tableDidRemoveRows):
+ (WI.CookieStorageContentView.prototype._reloadCookies):
+ Create Cookie objects from the payload instead of using raw payload data.
+
2018-12-13 Devin Rousso <[email protected]>
Web Inspector: remove DOM.BackendNodeId and associated commands/events
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Cookie.js (239225 => 239226)
--- trunk/Source/WebInspectorUI/UserInterface/Models/Cookie.js 2018-12-14 20:06:38 UTC (rev 239225)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Cookie.js 2018-12-14 20:41:31 UTC (rev 239226)
@@ -25,12 +25,12 @@
WI.Cookie = class Cookie
{
- constructor(type, name, value, raw, expires, maxAge, path, domain, secure, httpOnly, sameSite)
+ constructor(type, name, value, {header, expires, maxAge, path, domain, secure, httpOnly, sameSite, size} = {})
{
console.assert(Object.values(WI.Cookie.Type).includes(type));
console.assert(typeof name === "string");
console.assert(typeof value === "string");
- console.assert(!raw || typeof raw === "string");
+ console.assert(!header || typeof header === "string");
console.assert(!expires || expires instanceof Date);
console.assert(!maxAge || typeof maxAge === "number");
console.assert(!path || typeof path === "string");
@@ -38,37 +38,35 @@
console.assert(!secure || typeof secure === "boolean");
console.assert(!httpOnly || typeof httpOnly === "boolean");
console.assert(!sameSite || Object.values(WI.Cookie.SameSiteType).includes(sameSite));
+ console.assert(!size || typeof size === "number");
- this.type = type;
- this.name = name || "";
- this.value = value || "";
+ this._type = type;
+ this._name = name;
+ this._value = value;
+ this._size = size || this._name.length + this._value.length;
- if (this.type === WI.Cookie.Type.Response) {
- this.rawHeader = raw || "";
- this.expires = expires || null;
- this.maxAge = maxAge || null;
- this.path = path || null;
- this.domain = domain || null;
- this.secure = secure || false;
- this.httpOnly = httpOnly || false;
- this.sameSite = sameSite || WI.Cookie.SameSiteType.None;
+ if (this._type === WI.Cookie.Type.Response) {
+ this._header = header || "";
+ this._expires = expires || null;
+ this._maxAge = maxAge || null;
+ this._path = path || null;
+ this._domain = domain || null;
+ this._secure = secure || false;
+ this._httpOnly = httpOnly || false;
+ this._sameSite = sameSite || WI.Cookie.SameSiteType.None;
}
}
- // Public
+ // Static
- expirationDate(requestSentDate)
+ static fromPayload(payload)
{
- if (this.maxAge) {
- let startDate = requestSentDate || new Date;
- return new Date(startDate.getTime() + (this.maxAge * 1000));
- }
+ let {name, value, ...options} = payload;
+ options.expires = options.expires ? new Date(options.expires) : null;
- return this.expires;
+ return new WI.Cookie(WI.Cookie.Type.Response, name, value, options);
}
- // Static
-
// RFC 6265 defines the HTTP Cookie and Set-Cookie header fields:
// https://www.ietf.org/rfc/rfc6265.txt
@@ -212,8 +210,41 @@
}
}
- return new WI.Cookie(WI.Cookie.Type.Response, name, value, header, expires, maxAge, path, domain, secure, httpOnly, sameSite);
+ return new WI.Cookie(WI.Cookie.Type.Response, name, value, {header, expires, maxAge, path, domain, secure, httpOnly, sameSite});
}
+
+ // Public
+
+ get type() { return this._type; }
+ get name() { return this._name; }
+ get value() { return this._value; }
+ get header() { return this._header; }
+ get expires() { return this._expires; }
+ get maxAge() { return this._maxAge; }
+ get path() { return this._path; }
+ get domain() { return this._domain; }
+ get secure() { return this._secure; }
+ get httpOnly() { return this._httpOnly; }
+ get sameSite() { return this._sameSite; }
+ get size() { return this._size; }
+
+ get url()
+ {
+ let url = "" ? "https://" : "http://";
+ url += this._domain || "";
+ url += this._path || "";
+ return url;
+ }
+
+ expirationDate(requestSentDate)
+ {
+ if (this._maxAge) {
+ let startDate = requestSentDate || new Date;
+ return new Date(startDate.getTime() + (this._maxAge * 1000));
+ }
+
+ return this._expires;
+ }
};
WI.Cookie.Type = {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js (239225 => 239226)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js 2018-12-14 20:06:38 UTC (rev 239225)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js 2018-12-14 20:41:31 UTC (rev 239226)
@@ -132,10 +132,7 @@
this._cookies.splice(rowIndex, 1);
- // FIXME: <https://bugs.webkit.org/b/189533> add a WI.Cookie.url property
- // once we switch over to using model objects instead of raw payload data.
- let cookieURL = (cookie.secure ? "https://" : "http://") + cookie.domain + cookie.path;
- PageAgent.deleteCookie(cookie.name, cookieURL);
+ PageAgent.deleteCookie(cookie.name, cookie.url);
}
}
@@ -312,7 +309,7 @@
_reloadCookies()
{
PageAgent.getCookies().then((payload) => {
- this._cookies = this._filterCookies(payload.cookies);
+ this._cookies = this._filterCookies(payload.cookies.map(WI.Cookie.fromPayload));
this._updateSort();
this._table.reloadData();
}).catch((error) => {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js (239225 => 239226)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js 2018-12-14 20:06:38 UTC (rev 239225)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js 2018-12-14 20:41:31 UTC (rev 239226)
@@ -356,7 +356,7 @@
let responseCookies = this._resource.responseCookies;
console.assert(responseCookies.length > 0);
for (let cookie of responseCookies)
- this._responseHeadersSection.appendKeyValuePair(key, cookie.rawHeader, "header");
+ this._responseHeadersSection.appendKeyValuePair(key, cookie.header, "header");
continue;
}