Changeset 50477 in webkit
- Timestamp:
- Nov 3, 2009 1:12:24 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r50470 r50477 1 2009-11-03 Bradley Green <brg@chromium.org> 2 3 Reviewed by Dmitry Titov. 4 5 Updating test expectations for implementation of 6 window.navigator.registerProtocolHandler and 7 window.navigator.registerContentHandler. 8 9 There is a default implimentation for these APIs, hence all platforms 10 with the navigator-detached-no-crash-expect and 11 window-properties-expected tests needed to be updated. While 12 isolatedWorlds has a window-properties-expected test, it has no window 13 object and hence does not need to be updaetd. 14 15 We add two fast/dom tests to insure that the proper exceptions are 16 thrown when bad syntax or security violations are made by calling the 17 methods. 18 19 * fast/dom/Window/window-properties-expected.txt: 20 * fast/dom/navigator-detached-no-crash-expected.txt: 21 * fast/dom/navigator-detached-no-crash.html: 22 * fast/dom/registerContentHandler-expected.txt: Added. 23 * fast/dom/registerContentHandler.html: Added. 24 * fast/dom/registerProtocolHandler-expected.txt: Added. 25 * fast/dom/registerProtocolHandler.html: Added. 26 * platform/gtk/fast/dom/Window/window-properties-expected.txt: 27 * platform/gtk/fast/dom/navigator-detached-no-crash-expected.txt: 28 * platform/mac-leopard/fast/dom/navigator-detached-no-crash-expected.txt: 29 1 30 2009-11-03 Dan Bernstein <mitz@apple.com> 2 31 -
trunk/LayoutTests/fast/dom/Window/window-properties-expected.txt
r49998 r50477 1689 1689 window.clientInformation.product [string] 1690 1690 window.clientInformation.productSub [string] 1691 window.clientInformation.registerContentHandler [function] 1692 window.clientInformation.registerProtocolHandler [function] 1691 1693 window.clientInformation.userAgent [string] 1692 1694 window.clientInformation.vendor [string] -
trunk/LayoutTests/fast/dom/navigator-detached-no-crash-expected.txt
r47397 r50477 14 14 navigator.product is OK 15 15 navigator.productSub is OK 16 navigator.registerContentHandler() threw err Error: SYNTAX_ERR: DOM Exception 12 17 navigator.registerProtocolHandler() threw err Error: SYNTAX_ERR: DOM Exception 12 16 18 navigator.userAgent is OK 17 19 navigator.vendor is OK … … 30 32 navigator.product is OK 31 33 navigator.productSub is OK 34 navigator.registerContentHandler() is OK 35 navigator.registerProtocolHandler() is OK 32 36 navigator.userAgent is OK 33 37 navigator.vendor is OK -
trunk/LayoutTests/fast/dom/navigator-detached-no-crash.html
r41087 r50477 54 54 for (p in old_nav) { 55 55 if (typeof old_nav[p] == 'function') { 56 var v = old_nav[p](); 57 // no crash, it is ok 58 strings.push("navigator."+p+"() is OK"); 56 try { 57 var v = old_nav[p](); 58 // no crash, it is ok 59 strings.push("navigator."+p+"() is OK"); 60 } catch(err) { 61 // navigator.registerXXX will throw on invalid input. 62 strings.push("navigator."+p+"() threw err "+err); 63 } 59 64 } else { 60 65 var v = old_nav[p]; -
trunk/LayoutTests/platform/gtk/fast/dom/Window/window-properties-expected.txt
r48362 r50477 1658 1658 window.clientInformation.product [string] 1659 1659 window.clientInformation.productSub [string] 1660 window.clientInformation.registerContentHandler [function] 1661 window.clientInformation.registerProtocolHandler [function] 1660 1662 window.clientInformation.userAgent [string] 1661 1663 window.clientInformation.vendor [string] -
trunk/LayoutTests/platform/gtk/fast/dom/navigator-detached-no-crash-expected.txt
r47864 r50477 15 15 navigator.product is OK 16 16 navigator.productSub is OK 17 navigator.registerContentHandler() threw err Error: SYNTAX_ERR: DOM Exception 12 18 navigator.registerProtocolHandler() threw err Error: SYNTAX_ERR: DOM Exception 12 17 19 navigator.userAgent is OK 18 20 navigator.vendor is OK … … 32 34 navigator.product is OK 33 35 navigator.productSub is OK 36 navigator.registerContentHandler() is OK 37 navigator.registerProtocolHandler() is OK 34 38 navigator.userAgent is OK 35 39 navigator.vendor is OK -
trunk/LayoutTests/platform/mac-leopard/fast/dom/navigator-detached-no-crash-expected.txt
r47397 r50477 14 14 navigator.product is OK 15 15 navigator.productSub is OK 16 navigator.registerContentHandler() threw err Error: SYNTAX_ERR: DOM Exception 12 17 navigator.registerProtocolHandler() threw err Error: SYNTAX_ERR: DOM Exception 12 16 18 navigator.userAgent is OK 17 19 navigator.vendor is OK … … 30 32 navigator.product is OK 31 33 navigator.productSub is OK 34 navigator.registerContentHandler() is OK 35 navigator.registerProtocolHandler() is OK 32 36 navigator.userAgent is OK 33 37 navigator.vendor is OK -
trunk/WebCore/ChangeLog
r50476 r50477 1 2009-11-03 Bradley Green <brg@chromium.org> 2 3 Reviewed by Dmitry Titov. 4 5 Implement window.navigator.registerProtocolHandler in webkit, 6 https://bugs.webkit.org/b/29651 7 8 Also implemented its sister API window.navigator.registerContentHandler. 9 10 These methods are as described in the HTML5 specification which can be 11 found here, 12 http://dev.w3.org/html5/spec/Overview.html#dom-navigator-registerprotocolhandler 13 http://dev.w3.org/html5/spec/Overview.html#dom-navigator-registercontenthandler 14 15 As specified in the document, the behavior of the browser is determined 16 by the current registered handler. The state of a registered handler 17 can change at any time, with the user clearing a registered handler, 18 registering a different page as handler, or deferring the hander to the 19 OS. If webkit was to track the state of the currently registered 20 handlers, it would need more APIs and complexity to keep in sync with 21 user actions reported to webkit from the UA. For simplicity, the state 22 of protocol handlers should be kept isolated from webkit and webkit only 23 notifies the UA that a page has made the call. The UA is then 24 responsible for correctly handling the registerProtocolHandler call and 25 the redirects which result from registration. 26 27 We do however follow the specification in insuring that the reserved 28 schemes and mimeTypes are not passed to the UA as custom handler 29 registration tests. We also insure that the "%s" token is present as 30 required by the specification. 31 32 Updated test expectations for window.clientInformation and navigator 33 objects. 34 35 Tests: fast/dom/registerContentHandler.html 36 fast/dom/registerProtocolHandler.html 37 38 * page/Chrome.cpp: 39 (WebCore::Chrome::registerProtocolHandler): 40 (WebCore::Chrome::registerContentHandler): 41 * page/Chrome.h: 42 * page/ChromeClient.h: 43 (WebCore::ChromeClient::registerProtocolHandler): 44 (WebCore::ChromeClient::registerContentHandler): 45 * page/Navigator.cpp: 46 (WebCore::verifyCustomHandlerURL): 47 (WebCore::verifyProtocolHandlerScheme): 48 (WebCore::Navigator::registerProtocolHandler): 49 (WebCore::verifyProtocolHandlerMimeType): 50 (WebCore::Navigator::registerContentHandler): 51 * page/Navigator.h: 52 * page/Navigator.idl: 53 1 54 2009-11-03 Brady Eidson <beidson@apple.com> 2 55 -
trunk/WebCore/page/Chrome.cpp
r50351 r50477 308 308 } 309 309 310 void Chrome::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title) 311 { 312 m_client->registerProtocolHandler(scheme, baseURL, url, title); 313 } 314 315 void Chrome::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title) 316 { 317 m_client->registerContentHandler(mimeType, baseURL, url, title); 318 } 319 310 320 IntRect Chrome::windowResizerRect() const 311 321 { -
trunk/WebCore/page/Chrome.h
r50351 r50477 118 118 bool shouldInterruptJavaScript(); 119 119 120 void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title); 121 void registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title); 122 120 123 IntRect windowResizerRect() const; 121 124 -
trunk/WebCore/page/ChromeClient.h
r50351 r50477 124 124 virtual bool tabsToLinks() const = 0; 125 125 126 virtual void registerProtocolHandler(const String&, const String&, const String&, const String&) { } 127 virtual void registerContentHandler(const String&, const String&, const String&, const String&) { } 128 126 129 virtual IntRect windowResizerRect() const = 0; 127 130 -
trunk/WebCore/page/Navigator.cpp
r47397 r50477 25 25 26 26 #include "CookieJar.h" 27 #include "ExceptionCode.h" 27 28 #include "Frame.h" 28 29 #include "FrameLoader.h" 29 30 #include "FrameLoaderClient.h" 30 31 #include "Geolocation.h" 32 #include "Kurl.h" 31 33 #include "Language.h" 32 34 #include "MimeTypeArray.h" … … 170 172 #endif 171 173 174 static bool verifyCustomHandlerURL(const String& baseURL, const String& url, ExceptionCode& ec) 175 { 176 // The specification requires that it is a SYNTAX_ERR if the the "%s" token is not present. 177 static const char token[] = "%s"; 178 int index = url.find(token); 179 if (-1 == index) { 180 ec = SYNTAX_ERR; 181 return false; 182 } 183 184 // It is also a SYNTAX_ERR if the custom handler URL, as created by removing 185 // the "%s" token and prepending the base url, does not resolve. 186 String newURL = url; 187 newURL.remove(index, sizeof(token) / sizeof(token[0])); 188 189 KURL base(ParsedURLString, baseURL); 190 KURL kurl(base, newURL); 191 192 if (kurl.isEmpty() || !kurl.isValid()) { 193 ec = SYNTAX_ERR; 194 return false; 195 } 196 197 return true; 198 } 199 200 static bool verifyProtocolHandlerScheme(const String& scheme, ExceptionCode& ec) 201 { 202 // It is a SECURITY_ERR for these schemes to be handled by a custom handler. 203 if (equalIgnoringCase(scheme, "http") || equalIgnoringCase(scheme, "https") || equalIgnoringCase(scheme, "file")) { 204 ec = SECURITY_ERR; 205 return false; 206 } 207 return true; 208 } 209 210 void Navigator::registerProtocolHandler(const String& scheme, const String& url, const String& title, ExceptionCode& ec) 211 { 212 if (!verifyProtocolHandlerScheme(scheme, ec)) 213 return; 214 215 if (!m_frame) 216 return; 217 218 Document* document = m_frame->document(); 219 if (!document) 220 return; 221 222 String baseURL = document->baseURL().baseAsString(); 223 224 if (!verifyCustomHandlerURL(baseURL, url, ec)) 225 return; 226 227 if (Page* page = m_frame->page()) 228 page->chrome()->registerProtocolHandler(scheme, baseURL, url, m_frame->displayStringModifiedByEncoding(title)); 229 } 230 231 static bool verifyProtocolHandlerMimeType(const String& type, ExceptionCode& ec) 232 { 233 // It is a SECURITY_ERR for these mime types to be assigned to a custom 234 // handler. 235 if (equalIgnoringCase(type, "text/html") || equalIgnoringCase(type, "text/css") || equalIgnoringCase(type, "application/x-javascript")) { 236 ec = SECURITY_ERR; 237 return false; 238 } 239 return true; 240 } 241 242 void Navigator::registerContentHandler(const String& mimeType, const String& url, const String& title, ExceptionCode& ec) 243 { 244 if (!verifyProtocolHandlerMimeType(mimeType, ec)) 245 return; 246 247 if (!m_frame) 248 return; 249 250 Document* document = m_frame->document(); 251 if (!document) 252 return; 253 254 String baseURL = document->baseURL().baseAsString(); 255 256 if (!verifyCustomHandlerURL(baseURL, url, ec)) 257 return; 258 259 if (Page* page = m_frame->page()) 260 page->chrome()->registerContentHandler(mimeType, baseURL, url, m_frame->displayStringModifiedByEncoding(title)); 261 } 262 172 263 } // namespace WebCore -
trunk/WebCore/page/Navigator.h
r47397 r50477 35 35 class String; 36 36 37 typedef int ExceptionCode; 38 37 39 class Navigator : public NavigatorBase, public RefCounted<Navigator> { 38 40 public: … … 61 63 #endif 62 64 65 void registerProtocolHandler(const String& scheme, const String& url, const String& title, ExceptionCode& ec); 66 void registerContentHandler(const String& mimeType, const String& url, const String& title, ExceptionCode& ec); 67 63 68 private: 64 69 Navigator(Frame*); -
trunk/WebCore/page/Navigator.idl
r47397 r50477 47 47 void getStorageUpdates(); 48 48 #endif 49 50 void registerProtocolHandler(in DOMString scheme, in DOMString url, in DOMString title) 51 raises(DomException); 52 void registerContentHandler(in DOMString mimeType, in DOMString url, in DOMString title) 53 raises(DomException); 49 54 }; 50 55
Note: See TracChangeset
for help on using the changeset viewer.