Changeset 163208 in webkit
- Timestamp:
- Jan 31, 2014 3:06:25 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 29 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r163205 r163208 1 2014-01-31 Maciej Stachowiak <mjs@apple.com> 2 3 Implement (most of) URL API 4 https://bugs.webkit.org/show_bug.cgi?id=127795 5 6 Reviewed by Alexey Proskuryakov. 7 8 Add a bunch of new tests for URL(), copied from HTMLAnchorElement API tests: 9 10 * fast/dom/DOMURL/get-href-attribute-port-expected.txt: Added. 11 * fast/dom/DOMURL/get-href-attribute-port.html: Added. 12 * fast/dom/DOMURL/resources: Added. 13 * fast/dom/DOMURL/resources/iframe-with-anchor.html: Added. 14 * fast/dom/DOMURL/set-href-attribute-hash-expected.txt: Added. 15 * fast/dom/DOMURL/set-href-attribute-hash.html: Added. 16 * fast/dom/DOMURL/set-href-attribute-host-expected.txt: Added. 17 * fast/dom/DOMURL/set-href-attribute-host.html: Added. 18 * fast/dom/DOMURL/set-href-attribute-hostname-expected.txt: Added. 19 * fast/dom/DOMURL/set-href-attribute-hostname.html: Added. 20 * fast/dom/DOMURL/set-href-attribute-pathname-expected.txt: Added. 21 * fast/dom/DOMURL/set-href-attribute-pathname.html: Added. 22 * fast/dom/DOMURL/set-href-attribute-port-expected.txt: Added. 23 * fast/dom/DOMURL/set-href-attribute-port.html: Added. 24 * fast/dom/DOMURL/set-href-attribute-protocol-expected.txt: Added. 25 * fast/dom/DOMURL/set-href-attribute-protocol.html: Added. 26 * fast/dom/DOMURL/set-href-attribute-search-expected.txt: Added. 27 * fast/dom/DOMURL/set-href-attribute-search.html: Added. 28 * fast/dom/DOMURL/set-href-attribute-whitespace-expected.txt: Added. 29 * fast/dom/DOMURL/set-href-attribute-whitespace.html: Added. 30 * fast/dom/DOMURL/url-origin-expected.txt: Added. 31 * fast/dom/DOMURL/url-origin.html: Added. 32 33 Brand new tests for username and password properties, accessors on invalid URLS, 34 and different constructor modes: 35 * fast/dom/DOMURL/invalid-url-getters-expected.txt: Added. 36 * fast/dom/DOMURL/invalid-url-getters.html: Added. 37 * fast/dom/DOMURL/url-constructor-expected.txt: Added. 38 * fast/dom/DOMURL/url-constructor.html: Added. 39 * fast/dom/DOMURL/url-password-expected.txt: Added. 40 * fast/dom/DOMURL/url-password.html: Added. 41 * fast/dom/DOMURL/url-username-expected.txt: Added. 42 * fast/dom/DOMURL/url-username.html: Added. 43 44 Update tests and results for the fact that URL constructor takes arguments. 45 * fast/dom/DOMURL/check-instanceof-domurl-functions.html: 46 * fast/dom/constructed-objects-prototypes-expected.txt: 47 * fast/dom/script-tests/constructed-objects-prototypes.js: 48 * js/dom/constructor-length.html: 49 * platform/efl/js/dom/constructor-length-expected.txt: 50 * platform/gtk-wk2/js/dom/constructor-length-expected.txt: 51 * platform/gtk/js/dom/constructor-length-expected.txt: 52 * platform/mac/js/dom/constructor-length-expected.txt: 53 1 54 2014-01-31 Bem Jones-Bey <bjonesbe@adobe.com> 2 55 -
trunk/LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions.html
r155265 r163208 8 8 description("Test instanceof functions and properties of URL and webkitURL."); 9 9 10 var url = new URL ;10 var url = new URL("about:blank"); 11 11 12 12 shouldBeTrue("'createObjectURL' in URL"); -
trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt
r149001 r163208 14 14 PASS (new inner.ProgressEvent()).isInner is true 15 15 PASS (new inner.ProgressEvent()).constructor.isInner is true 16 PASS (new inner.URL( )).isInner is true17 PASS (new inner.URL( )).constructor.isInner is true16 PASS (new inner.URL('about:blank')).isInner is true 17 PASS (new inner.URL('about:blank')).constructor.isInner is true 18 18 PASS (new inner.XMLHttpRequest()).isInner is true 19 19 PASS (new inner.XMLHttpRequest()).constructor.isInner is true -
trunk/LayoutTests/fast/dom/script-tests/constructed-objects-prototypes.js
r149001 r163208 12 12 13 13 var argumentsForConstructor = { 14 'URL' : "'about:blank'", 14 15 'Worker' : "'foo'", 15 16 } -
trunk/LayoutTests/js/dom/constructor-length.html
r156066 r163208 55 55 shouldBe('WebSocket.length', '1'); 56 56 shouldBe('Worker.length', '1'); 57 shouldBe('URL.length', ' 0');57 shouldBe('URL.length', '1'); 58 58 shouldBe('XMLHttpRequest.length', '0'); 59 59 shouldBe('XMLSerializer.length', '0'); -
trunk/LayoutTests/platform/efl/js/dom/constructor-length-expected.txt
r158660 r163208 51 51 PASS WebSocket.length is 1 52 52 PASS Worker.length is 1 53 PASS URL.length is 053 PASS URL.length is 1 54 54 PASS XMLHttpRequest.length is 0 55 55 PASS XMLSerializer.length is 0 -
trunk/LayoutTests/platform/gtk-wk2/js/dom/constructor-length-expected.txt
r156412 r163208 51 51 PASS WebSocket.length is 1 52 52 PASS Worker.length is 1 53 PASS URL.length is 053 PASS URL.length is 1 54 54 PASS XMLHttpRequest.length is 0 55 55 PASS XMLSerializer.length is 0 -
trunk/LayoutTests/platform/gtk/js/dom/constructor-length-expected.txt
r156704 r163208 51 51 PASS WebSocket.length is 1 52 52 PASS Worker.length is 1 53 PASS URL.length is 053 PASS URL.length is 1 54 54 PASS XMLHttpRequest.length is 0 55 55 PASS XMLSerializer.length is 0 -
trunk/LayoutTests/platform/mac/js/dom/constructor-length-expected.txt
r156066 r163208 51 51 PASS WebSocket.length is 1 52 52 PASS Worker.length is 1 53 PASS URL.length is 053 PASS URL.length is 1 54 54 PASS XMLHttpRequest.length is 0 55 55 PASS XMLSerializer.length is 0 -
trunk/Source/WebCore/CMakeLists.txt
r163195 r163208 493 493 html/TextMetrics.idl 494 494 html/TimeRanges.idl 495 html/URLUtils.idl 495 496 html/ValidityState.idl 496 497 html/VoidCallback.idl -
trunk/Source/WebCore/ChangeLog
r163205 r163208 1 2014-01-30 Maciej Stachowiak <mjs@apple.com> 2 3 Implement (most of) URL API 4 https://bugs.webkit.org/show_bug.cgi?id=127795 5 6 Reviewed by Alexey Proskuryakov. 7 8 Tests: fast/dom/DOMURL/get-href-attribute-port.html 9 fast/dom/DOMURL/invalid-url-getters.html 10 fast/dom/DOMURL/set-href-attribute-hash.html 11 fast/dom/DOMURL/set-href-attribute-host.html 12 fast/dom/DOMURL/set-href-attribute-hostname.html 13 fast/dom/DOMURL/set-href-attribute-pathname.html 14 fast/dom/DOMURL/set-href-attribute-port.html 15 fast/dom/DOMURL/set-href-attribute-protocol.html 16 fast/dom/DOMURL/set-href-attribute-search.html 17 fast/dom/DOMURL/set-href-attribute-whitespace.html 18 fast/dom/DOMURL/url-constructor.html 19 fast/dom/DOMURL/url-origin.html 20 fast/dom/DOMURL/url-password.html 21 fast/dom/DOMURL/url-username.html 22 23 * CMakeLists.txt: Update for new IDL file. 24 * DerivedSources.make: ditto 25 * GNUmakefile.list.am: ditto 26 * html/DOMURL.cpp: Implement URL() constructor and instance methods; cribbed from 27 HTMLAnchorElement mostly 28 (WebCore::DOMURL::DOMURL): 29 (WebCore::DOMURL::href): 30 (WebCore::DOMURL::setHref): 31 (WebCore::DOMURL::toString): 32 (WebCore::DOMURL::origin): 33 (WebCore::DOMURL::protocol): 34 (WebCore::DOMURL::setProtocol): 35 (WebCore::DOMURL::username): 36 (WebCore::DOMURL::setUsername): 37 (WebCore::DOMURL::password): 38 (WebCore::DOMURL::setPassword): 39 (WebCore::DOMURL::host): 40 (WebCore::parsePortFromStringPosition): 41 (WebCore::DOMURL::setHost): 42 (WebCore::DOMURL::hostname): 43 (WebCore::DOMURL::setHostname): 44 (WebCore::DOMURL::port): 45 (WebCore::DOMURL::setPort): 46 (WebCore::DOMURL::pathname): 47 (WebCore::DOMURL::setPathname): 48 (WebCore::DOMURL::search): 49 (WebCore::DOMURL::setSearch): 50 (WebCore::DOMURL::hash): 51 (WebCore::DOMURL::setHash): 52 * html/DOMURL.h: 53 (WebCore::DOMURL::create): 54 * html/DOMURL.idl: Update for new methods. 55 * html/URLUtils.idl: Added. New IDL file that contains most of the interface. 56 1 57 2014-01-31 Bem Jones-Bey <bjonesbe@adobe.com> 2 58 -
trunk/Source/WebCore/DerivedSources.make
r162795 r163208 405 405 $(WebCore)/html/TextMetrics.idl \ 406 406 $(WebCore)/html/TimeRanges.idl \ 407 $(WebCore)/html/URLUtils.idl \ 407 408 $(WebCore)/html/ValidityState.idl \ 408 409 $(WebCore)/html/VoidCallback.idl \ -
trunk/Source/WebCore/GNUmakefile.list.am
r163180 r163208 1499 1499 $(WebCore)/html/TextMetrics.idl \ 1500 1500 $(WebCore)/html/TimeRanges.idl \ 1501 $(WebCore)/html/URLUtils.idl \ 1501 1502 $(WebCore)/html/ValidityState.idl \ 1502 1503 $(WebCore)/html/VoidCallback.idl \ -
trunk/Source/WebCore/html/DOMURL.cpp
r158650 r163208 1 1 /* 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * (C) 2000 Simon Hausmann <hausmann@kde.org> 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010, 2014 Apple Inc. All rights reserved. 6 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 2 7 * Copyright (C) 2011 Google Inc. All rights reserved. 3 8 * Copyright (C) 2012 Motorola Mobility Inc. 4 9 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Library General Public 12 * License as published by the Free Software Foundation; either 13 * version 2 of the License, or (at your option) any later version. 8 14 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Library General Public License for more details. 14 19 * 15 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 20 * You should have received a copy of the GNU Library General Public License 21 * along with this library; see the file COPYING.LIB. If not, write to 22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 23 * Boston, MA 02110-1301, USA. 25 24 */ 26 25 27 26 #include "config.h" 27 #include "DOMURL.h" 28 29 #include "SecurityOrigin.h" 28 30 29 31 #if ENABLE(BLOB) 30 31 #include "DOMURL.h"32 33 32 #include "ActiveDOMObject.h" 34 33 #include "Blob.h" … … 38 37 #include "ResourceRequest.h" 39 38 #include "ScriptExecutionContext.h" 40 #include "SecurityOrigin.h"41 39 #include <wtf/MainThread.h> 40 #endif // ENABLE(BLOB) 42 41 43 42 namespace WebCore { 43 44 PassRefPtr<DOMURL> DOMURL::create(const String& url, const String& base, ExceptionCode& ec) 45 { 46 return adoptRef(new DOMURL(url, base, ec)); 47 } 48 49 PassRefPtr<DOMURL> DOMURL::create(const String& url, const DOMURL* base, ExceptionCode& ec) 50 { 51 ASSERT(base); 52 return adoptRef(new DOMURL(url, *base, ec)); 53 } 54 55 PassRefPtr<DOMURL> DOMURL::create(const String& url, ExceptionCode& ec) 56 { 57 return adoptRef(new DOMURL(url, ec)); 58 } 59 60 inline DOMURL::DOMURL(const String& url, const String& base, ExceptionCode& ec) 61 : m_baseURL(URL(), base) 62 , m_url(m_baseURL, url) 63 { 64 if (!m_baseURL.isValid() || !m_url.isValid()) 65 ec = TypeError; 66 } 67 68 inline DOMURL::DOMURL(const String& url, const DOMURL& base, ExceptionCode& ec) 69 : m_baseURL(base.href()) 70 , m_url(m_baseURL, url) 71 { 72 if (!m_baseURL.isValid() || !m_url.isValid()) 73 ec = TypeError; 74 } 75 76 inline DOMURL::DOMURL(const String& url, ExceptionCode& ec) 77 : m_baseURL(blankURL()) 78 , m_url(m_baseURL, url) 79 { 80 if (!m_url.isValid()) 81 ec = TypeError; 82 } 83 84 const URL& DOMURL::href() const 85 { 86 return m_url; 87 } 88 89 void DOMURL::setHref(const String& url) 90 { 91 m_url = URL(m_baseURL, url); 92 } 93 94 void DOMURL::setHref(const String& url, ExceptionCode& ec) 95 { 96 setHref(url); 97 if (!m_url.isValid()) 98 ec = TypeError; 99 } 100 101 const String& DOMURL::toString() const 102 { 103 return href().string(); 104 } 105 106 String DOMURL::origin() const 107 { 108 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(href()); 109 return origin->toString(); 110 } 111 112 String DOMURL::protocol() const 113 { 114 return href().protocol() + ':'; 115 } 116 117 void DOMURL::setProtocol(const String& value) 118 { 119 URL url = href(); 120 url.setProtocol(value); 121 setHref(url.string()); 122 } 123 124 String DOMURL::username() const 125 { 126 return href().user(); 127 } 128 129 void DOMURL::setUsername(const String& user) 130 { 131 URL url = href(); 132 url.setUser(user); 133 setHref(url); 134 } 135 136 String DOMURL::password() const 137 { 138 return href().pass(); 139 } 140 141 void DOMURL::setPassword(const String& pass) 142 { 143 URL url = href(); 144 url.setPass(pass); 145 setHref(url); 146 } 147 148 String DOMURL::host() const 149 { 150 const URL& url = href(); 151 if (url.hostEnd() == url.pathStart()) 152 return url.host(); 153 if (isDefaultPortForProtocol(url.port(), url.protocol())) 154 return url.host(); 155 return url.host() + ':' + String::number(url.port()); 156 } 157 158 // This function does not allow leading spaces before the port number. 159 static unsigned parsePortFromStringPosition(const String& value, unsigned portStart, unsigned& portEnd) 160 { 161 portEnd = portStart; 162 while (isASCIIDigit(value[portEnd])) 163 ++portEnd; 164 return value.substring(portStart, portEnd - portStart).toUInt(); 165 } 166 167 void DOMURL::setHost(const String& value) 168 { 169 if (value.isEmpty()) 170 return; 171 URL url = href(); 172 if (!url.canSetHostOrPort()) 173 return; 174 175 size_t separator = value.find(':'); 176 if (!separator) 177 return; 178 179 if (separator == notFound) 180 url.setHostAndPort(value); 181 else { 182 unsigned portEnd; 183 unsigned port = parsePortFromStringPosition(value, separator + 1, portEnd); 184 if (!port) { 185 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes 186 // specifically goes against RFC 3986 (p3.2) and 187 // requires setting the port to "0" if it is set to empty string. 188 url.setHostAndPort(value.substring(0, separator + 1) + '0'); 189 } else { 190 if (isDefaultPortForProtocol(port, url.protocol())) 191 url.setHostAndPort(value.substring(0, separator)); 192 else 193 url.setHostAndPort(value.substring(0, portEnd)); 194 } 195 } 196 setHref(url.string()); 197 } 198 199 String DOMURL::hostname() const 200 { 201 return href().host(); 202 } 203 204 void DOMURL::setHostname(const String& value) 205 { 206 // Before setting new value: 207 // Remove all leading U+002F SOLIDUS ("/") characters. 208 unsigned i = 0; 209 unsigned hostLength = value.length(); 210 while (value[i] == '/') 211 i++; 212 213 if (i == hostLength) 214 return; 215 216 URL url = href(); 217 if (!url.canSetHostOrPort()) 218 return; 219 220 url.setHost(value.substring(i)); 221 setHref(url.string()); 222 } 223 224 String DOMURL::port() const 225 { 226 if (href().hasPort()) 227 return String::number(href().port()); 228 229 return emptyString(); 230 } 231 232 void DOMURL::setPort(const String& value) 233 { 234 URL url = href(); 235 if (!url.canSetHostOrPort()) 236 return; 237 238 // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes 239 // specifically goes against RFC 3986 (p3.2) and 240 // requires setting the port to "0" if it is set to empty string. 241 // FIXME: http://url.spec.whatwg.org/ doesn't appear to require this; test what browsers do 242 unsigned port = value.toUInt(); 243 if (isDefaultPortForProtocol(port, url.protocol())) 244 url.removePort(); 245 else 246 url.setPort(port); 247 248 setHref(url.string()); 249 } 250 251 String DOMURL::pathname() const 252 { 253 return href().path(); 254 } 255 256 void DOMURL::setPathname(const String& value) 257 { 258 URL url = href(); 259 if (!url.canSetPathname()) 260 return; 261 262 if (value[0] == '/') 263 url.setPath(value); 264 else 265 url.setPath("/" + value); 266 267 setHref(url.string()); 268 } 269 270 String DOMURL::search() const 271 { 272 String query = href().query(); 273 return query.isEmpty() ? emptyString() : "?" + query; 274 } 275 276 void DOMURL::setSearch(const String& value) 277 { 278 URL url = href(); 279 String newSearch = (value[0] == '?') ? value.substring(1) : value; 280 // Make sure that '#' in the query does not leak to the hash. 281 url.setQuery(newSearch.replaceWithLiteral('#', "%23")); 282 283 setHref(url.string()); 284 } 285 286 String DOMURL::hash() const 287 { 288 String fragmentIdentifier = href().fragmentIdentifier(); 289 if (fragmentIdentifier.isEmpty()) 290 return emptyString(); 291 return AtomicString(String("#" + fragmentIdentifier)); 292 } 293 294 void DOMURL::setHash(const String& value) 295 { 296 URL url = href(); 297 if (value[0] == '#') 298 url.setFragmentIdentifier(value.substring(1)); 299 else 300 url.setFragmentIdentifier(value); 301 setHref(url.string()); 302 } 303 304 #if ENABLE(BLOB) 44 305 45 306 String DOMURL::createObjectURL(ScriptExecutionContext* scriptExecutionContext, Blob* blob) … … 76 337 } 77 338 339 #endif // ENABLE(BLOB) 340 78 341 } // namespace WebCore 79 80 #endif // ENABLE(BLOB) -
trunk/Source/WebCore/html/DOMURL.h
r156550 r163208 28 28 #define DOMURL_h 29 29 30 #include "ExceptionCode.h" 30 31 #include "URL.h" 31 32 #include <wtf/HashSet.h> … … 43 44 44 45 public: 45 static PassRefPtr<DOMURL> create() { return adoptRef(new DOMURL); } 46 static PassRefPtr<DOMURL> create(const String& url, const String& base, ExceptionCode&); 47 static PassRefPtr<DOMURL> create(const String& url, const DOMURL* base, ExceptionCode&); 48 static PassRefPtr<DOMURL> create(const String& url, ExceptionCode&); 49 50 const URL& href() const; 51 void setHref(const String& url); 52 void setHref(const String&, ExceptionCode&); 53 const String& toString() const; 54 55 String origin() const; 56 57 String protocol() const; 58 void setProtocol(const String&); 59 60 String username() const; 61 void setUsername(const String&); 62 63 String password() const; 64 void setPassword(const String&); 65 66 String host() const; 67 void setHost(const String&); 68 69 String hostname() const; 70 void setHostname(const String&); 71 72 String port() const; 73 void setPort(const String&); 74 75 String pathname() const; 76 void setPathname(const String&); 77 78 String search() const; 79 void setSearch(const String&); 80 81 String hash() const; 82 void setHash(const String&); 83 46 84 47 85 #if ENABLE(BLOB) … … 53 91 static String createPublicURL(ScriptExecutionContext*, URLRegistrable*); 54 92 #endif 93 private: 94 DOMURL(const String& url, const String& base, ExceptionCode&); 95 DOMURL(const String& url, const DOMURL& base, ExceptionCode&); 96 DOMURL(const String& url, ExceptionCode&); 97 98 URL m_baseURL; 99 URL m_url; 55 100 }; 56 101 -
trunk/Source/WebCore/html/DOMURL.idl
r162878 r163208 27 27 [ 28 28 GlobalContext=DOMWindow&WorkerGlobalScope, 29 Constructor, 29 Constructor(DOMString url), 30 Constructor(DOMString url, DOMString base), 31 Constructor(DOMString url, DOMURL base), 32 ConstructorRaisesException, 30 33 JSGenerateToNativeObject, 31 34 JSGenerateToJSObject, … … 37 40 [CallWith=ScriptExecutionContext,Conditional=BLOB] static void revokeObjectURL(DOMString url); 38 41 }; 42 43 DOMURL implements URLUtils;
Note: See TracChangeset
for help on using the changeset viewer.