Changeset 51846 in webkit
- Timestamp:
- Dec 8, 2009 5:21:03 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r51843 r51846 1 2009-12-08 Alexander Pavlov <apavlov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Change the way cookies are retrieved in the WebInspector frontend. 6 7 Moved the cookie filtering from the native code into the frontend so that 8 all cookies can be retrieved regardless of the associated domain 9 (required for certain audits to run.) 10 https://bugs.webkit.org/show_bug.cgi?id=32160 11 12 * inspector/cookie-resource-match-expected.txt: Added. 13 * inspector/cookie-resource-match.html: Added. 14 1 15 2009-12-08 Nikolas Zimmermann <nzimmermann@rim.com> 2 16 -
trunk/WebCore/ChangeLog
r51845 r51846 1 2009-12-08 Alexander Pavlov <apavlov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Change the way cookies are retrieved in the WebInspector frontend. 6 7 Moved the cookie filtering from the native code into the frontend so that 8 all cookies can be retrieved regardless of the associated domain 9 (required for certain audits to run.) 10 https://bugs.webkit.org/show_bug.cgi?id=32160 11 12 Test: inspector/cookie-resource-match.html 13 14 * inspector/InspectorBackend.cpp: 15 (WebCore::InspectorBackend::getCookies): 16 * inspector/InspectorBackend.h: 17 * inspector/InspectorBackend.idl: 18 * inspector/InspectorController.cpp: 19 (WebCore::InspectorController::getCookies): 20 * inspector/InspectorController.h: 21 * inspector/front-end/CookieItemsView.js: 22 (WebInspector.CookieItemsView.prototype.update.callback): 23 (WebInspector.CookieItemsView.prototype.update): 24 (WebInspector.CookieItemsView.prototype._cookiesForDomain): 25 * inspector/front-end/DOMAgent.js: 26 (WebInspector.Cookies.getCookiesAsync): 27 (WebInspector.Cookies.cookieMatchesResourceURL): 28 (WebInspector.Cookies.cookieDomainMatchesResourceDomain): 29 * inspector/front-end/Resource.js: 30 (WebInspector.Resource): 31 (WebInspector.Resource.prototype.get documentURL): 32 (WebInspector.Resource.prototype.set documentURL): 33 * inspector/front-end/inspector.js: 34 (WebInspector.addResource): 35 1 36 2009-12-08 Nikolas Zimmermann <nzimmermann@rim.com> 2 37 -
trunk/WebCore/inspector/InspectorBackend.cpp
r51528 r51846 358 358 } 359 359 360 void InspectorBackend::getCookies(long callId , const String& domain)360 void InspectorBackend::getCookies(long callId) 361 361 { 362 362 if (!m_inspectorController) 363 363 return; 364 m_inspectorController->getCookies(callId , domain);364 m_inspectorController->getCookies(callId); 365 365 } 366 366 -
trunk/WebCore/inspector/InspectorBackend.h
r51528 r51846 115 115 void hideDOMNodeHighlight(); 116 116 117 void getCookies(long callId , const String& domain);117 void getCookies(long callId); 118 118 void deleteCookie(const String& cookieName, const String& domain); 119 119 -
trunk/WebCore/inspector/InspectorBackend.idl
r51528 r51846 88 88 void hideDOMNodeHighlight(); 89 89 90 void getCookies(in long callId , in DOMString domain);90 void getCookies(in long callId); 91 91 void deleteCookie(in DOMString cookieName, in DOMString domain); 92 92 -
trunk/WebCore/inspector/InspectorController.cpp
r51631 r51846 1150 1150 #endif 1151 1151 1152 void InspectorController::getCookies(long callId , const String& host)1152 void InspectorController::getCookies(long callId) 1153 1153 { 1154 1154 if (!m_frontend) 1155 1155 return; 1156 1156 1157 1157 // If we can get raw cookies. 1158 1158 ListHashSet<Cookie> rawCookiesList; 1159 1159 1160 1160 // If we can't get raw cookies - fall back to String representation 1161 1161 String stringCookiesList; 1162 1162 1163 1163 // Return value to getRawCookies should be the same for every call because 1164 1164 // the return value is platform/network backend specific, and the call will 1165 1165 // always return the same true/false value. 1166 1166 bool rawCookiesImplemented = false; 1167 1167 1168 1168 ResourcesMap::iterator resourcesEnd = m_resources.end(); 1169 1169 for (ResourcesMap::iterator it = m_resources.begin(); it != resourcesEnd; ++it) { 1170 1170 Document* document = it->second->frame()->document(); 1171 if (document->url().host() == host) { 1172 Vector<Cookie> docCookiesList; 1173 rawCookiesImplemented = getRawCookies(document, document->cookieURL(), docCookiesList); 1174 1175 if (!rawCookiesImplemented) { 1176 // FIXME: We need duplication checking for the String representation of cookies. 1177 ExceptionCode ec = 0; 1178 stringCookiesList += document->cookie(ec); 1179 // Exceptions are thrown by cookie() in sandboxed frames. That won't happen here 1180 // because "document" is the document of the main frame of the page. 1181 ASSERT(!ec); 1182 } else { 1183 int cookiesSize = docCookiesList.size(); 1184 for (int i = 0; i < cookiesSize; i++) { 1185 if (!rawCookiesList.contains(docCookiesList[i])) 1186 rawCookiesList.add(docCookiesList[i]); 1187 } 1171 Vector<Cookie> docCookiesList; 1172 rawCookiesImplemented = getRawCookies(document, document->cookieURL(), docCookiesList); 1173 1174 if (!rawCookiesImplemented) { 1175 // FIXME: We need duplication checking for the String representation of cookies. 1176 ExceptionCode ec = 0; 1177 stringCookiesList += document->cookie(ec); 1178 // Exceptions are thrown by cookie() in sandboxed frames. That won't happen here 1179 // because "document" is the document of the main frame of the page. 1180 ASSERT(!ec); 1181 } else { 1182 int cookiesSize = docCookiesList.size(); 1183 for (int i = 0; i < cookiesSize; i++) { 1184 if (!rawCookiesList.contains(docCookiesList[i])) 1185 rawCookiesList.add(docCookiesList[i]); 1188 1186 } 1189 1187 } 1190 1188 } 1191 1189 1192 1190 if (!rawCookiesImplemented) 1193 1191 m_frontend->didGetCookies(callId, m_frontend->newScriptArray(), stringCookiesList); -
trunk/WebCore/inspector/InspectorController.h
r51631 r51846 187 187 void mainResourceFiredDOMContentEvent(DocumentLoader*, const KURL&); 188 188 189 void getCookies(long callId , const String& url);189 void getCookies(long callId); 190 190 191 191 #if ENABLE(DATABASE) -
trunk/WebCore/inspector/front-end/CookieItemsView.js
r51528 r51846 68 68 69 69 var self = this; 70 function callback(cookies, isAdvanced) { 70 function callback(allCookies, isAdvanced) { 71 var cookies = self._cookiesForDomain(allCookies); 71 72 var dataGrid = (isAdvanced ? self.dataGridForCookies(cookies) : self.simpleDataGridForCookies(cookies)); 72 73 if (dataGrid) { … … 86 87 } 87 88 88 WebInspector.Cookies.getCookiesAsync(callback, this._cookieDomain); 89 WebInspector.Cookies.getCookiesAsync(callback); 90 }, 91 92 _cookiesForDomain: function(allCookies) 93 { 94 var cookiesForDomain = []; 95 var resourceURLsForDocumentURL = []; 96 97 for (var id in WebInspector.resources) { 98 var resource = WebInspector.resources[id]; 99 var match = resource.documentURL.match(WebInspector.URLRegExp); 100 if (match && match[2] === this._cookieDomain) 101 resourceURLsForDocumentURL.push(resource.url); 102 } 103 104 for (var i = 0; i < allCookies.length; ++i) { 105 for (var j = 0; j < resourceURLsForDocumentURL.length; ++j) { 106 var resourceURL = resourceURLsForDocumentURL[j]; 107 if (WebInspector.Cookies.cookieMatchesResourceURL(allCookies[i], resourceURL)) { 108 cookiesForDomain.push(allCookies[i]); 109 break; 110 } 111 } 112 } 113 return cookiesForDomain; 89 114 }, 90 115 -
trunk/WebCore/inspector/front-end/DOMAgent.js
r51601 r51846 440 440 WebInspector.Cookies = {} 441 441 442 WebInspector.Cookies.getCookiesAsync = function(callback , cookieDomain)442 WebInspector.Cookies.getCookiesAsync = function(callback) 443 443 { 444 444 function mycallback(cookies, cookiesString) { … … 449 449 } 450 450 var callId = WebInspector.Callback.wrap(mycallback); 451 InspectorBackend.getCookies(callId , cookieDomain);451 InspectorBackend.getCookies(callId); 452 452 } 453 453 … … 469 469 470 470 return cookies; 471 } 472 473 WebInspector.Cookies.cookieMatchesResourceURL = function(cookie, resourceURL) 474 { 475 var match = resourceURL.match(WebInspector.URLRegExp); 476 if (!match) 477 return false; 478 // See WebInspector.URLRegExp for definitions of the group index constants. 479 if (!this.cookieDomainMatchesResourceDomain(cookie.domain, match[2])) 480 return false; 481 var resourcePort = match[3] ? match[3] : undefined; 482 var resourcePath = match[4] ? match[4] : '/'; 483 return (resourcePath.indexOf(cookie.path) === 0 484 && (!cookie.port || resourcePort == cookie.port) 485 && (!cookie.secure || match[1].toLowerCase() === 'https')); 486 } 487 488 WebInspector.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain, resourceDomain) 489 { 490 if (cookieDomain.charAt(0) !== '.') 491 return resourceDomain === cookieDomain; 492 return !!resourceDomain.match(new RegExp("^([^\\.]+\\.)?" + cookieDomain.substring(1).escapeForRegExp() + "$"), "i"); 471 493 } 472 494 -
trunk/WebCore/inspector/front-end/Resource.js
r51229 r51846 27 27 */ 28 28 29 WebInspector.Resource = function(requestHeaders, url, do main, path, lastPathComponent, identifier, mainResource, cached, requestMethod, requestFormData)29 WebInspector.Resource = function(requestHeaders, url, documentURL, domain, path, lastPathComponent, identifier, mainResource, cached, requestMethod, requestFormData) 30 30 { 31 31 this.identifier = identifier; … … 36 36 this.requestHeaders = requestHeaders; 37 37 this.url = url; 38 this.documentURL = documentURL; 38 39 this.domain = domain; 39 40 this.path = path; … … 163 164 }, 164 165 166 get documentURL() 167 { 168 return this._documentURL; 169 }, 170 171 set documentURL(x) 172 { 173 if (this._documentURL === x) 174 return; 175 this._documentURL = x; 176 }, 177 165 178 get domain() 166 179 { -
trunk/WebCore/inspector/front-end/inspector.js
r51839 r51846 75 75 pendingDispatches: 0, 76 76 77 // RegExp groups: 78 // 1 - scheme 79 // 2 - hostname 80 // 3 - ?port 81 // 4 - ?path 82 // 5 - ?fragment 83 URLRegExp: /^(http[s]?|file):\/\/([^\/:]+)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i, 84 77 85 get platform() 78 86 { … … 1010 1018 payload.requestHeaders, 1011 1019 payload.requestURL, 1020 payload.documentURL, 1012 1021 payload.host, 1013 1022 payload.path,
Note: See TracChangeset
for help on using the changeset viewer.