WebKit Bugzilla
Attachment 356679 Details for
Bug 189533
: Web Inspector: Cookies view should use model objects instead of raw payload data
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-189533-20181205165225.patch (text/plain), 11.21 KB, created by
Matt Baker
on 2018-12-05 16:52:34 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Matt Baker
Created:
2018-12-05 16:52:34 PST
Size:
11.21 KB
patch
obsolete
>Subversion Revision: 238904 >diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index b4fdaa2972780d0cabc2f4640cac09fb81bd77ec..e840504007ee301b287c6a549fcd8418f5318788 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,37 @@ >+2018-12-05 Matt Baker <mattbaker@apple.com> >+ >+ 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-04 Nikita Vasilyev <nvasilyev@apple.com> > > Web Inspector: Add style editing debug mode >diff --git a/Source/WebInspectorUI/UserInterface/Models/Cookie.js b/Source/WebInspectorUI/UserInterface/Models/Cookie.js >index 46729426955016bd806d200d9124fcbb4498db4e..04bb22ef2768d9f8c8d8ccfc57eb3feef3a8dbef 100644 >--- a/Source/WebInspectorUI/UserInterface/Models/Cookie.js >+++ b/Source/WebInspectorUI/UserInterface/Models/Cookie.js >@@ -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 @@ WI.Cookie = class Cookie > 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 || ""; >- >- 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; >+ 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._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,7 +210,40 @@ WI.Cookie = class Cookie > } > } > >- 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 = this._secure ? "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; > } > }; > >diff --git a/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js b/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js >index d0c2b43a123d398c1dbcdab1486f5fe49e4452d2..3aa2d9e0e311d9a4ed3a6891efb5920a620c7ef9 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js >@@ -132,10 +132,7 @@ WI.CookieStorageContentView = class CookieStorageContentView extends WI.ContentV > > 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 @@ WI.CookieStorageContentView = class CookieStorageContentView extends WI.ContentV > _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) => { >diff --git a/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js b/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js >index d1a7e09b677a34acf7953187ade07bccd73958f2..3ca8415cda37dddc8d30b04418aaac1c28d80915 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js >@@ -356,7 +356,7 @@ WI.ResourceHeadersContentView = class ResourceHeadersContentView extends WI.Cont > 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; > } > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index f26e561bc52f077f52c3092dae66902fccd26d2b..f54c80f7677a96fb821732870b7e7294e7e9110c 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2018-12-05 Matt Baker <mattbaker@apple.com> >+ >+ 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-05 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r238844, r238846, and r238874. >diff --git a/LayoutTests/inspector/unit-tests/cookie-expected.txt b/LayoutTests/inspector/unit-tests/cookie-expected.txt >index e4dd1caa90b29a6b1573d8898802f2a8120d4dcc..66a63a7dd96841d3ac71902602e7fdd4e52fad97 100644 >--- a/LayoutTests/inspector/unit-tests/cookie-expected.txt >+++ b/LayoutTests/inspector/unit-tests/cookie-expected.txt >@@ -201,3 +201,8 @@ PASS: cookie.secure should be 'false'. > 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'. >+ >diff --git a/LayoutTests/inspector/unit-tests/cookie.html b/LayoutTests/inspector/unit-tests/cookie.html >index f01e5cce5840a60f6ee364439c7a4063caad25e2..e4cfe27ead58d8393b61a3d3a1dfa668dce5b22d 100644 >--- a/LayoutTests/inspector/unit-tests/cookie.html >+++ b/LayoutTests/inspector/unit-tests/cookie.html >@@ -210,6 +210,23 @@ function test() > } > }); > >+ 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>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189533
:
349496
|
349518
|
349608
|
349617
|
349632
|
349633
|
354298
|
356635
|
356679
|
356690
|
356691
|
356697
|
357293