Bug 46610

Summary: Implement getParameter from the URL API
Product: WebKit Reporter: Adam Barth <abarth>
Component: New BugsAssignee: Adam Barth <abarth>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, arv, commit-queue, dbates, dglazkov, eric, ossy, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing commit-queue: commit-queue-

Adam Barth
Reported 2010-09-27 00:22:47 PDT
Implement getParameter from the URL API
Attachments
Patch (10.96 KB, patch)
2010-09-27 00:26 PDT, Adam Barth
no flags
Patch (12.46 KB, patch)
2010-09-27 21:10 PDT, Adam Barth
no flags
Patch for landing (12.43 KB, patch)
2010-10-13 14:44 PDT, Adam Barth
commit-queue: commit-queue-
Adam Barth
Comment 1 2010-09-27 00:26:44 PDT
WebKit Review Bot
Comment 2 2010-09-27 02:37:57 PDT
Adam Barth
Comment 3 2010-09-27 10:02:51 PDT
Hum... Looks like I need a GURL implementation of the KURL part of this change.
Adam Barth
Comment 4 2010-09-27 21:10:54 PDT
Adam Barth
Comment 5 2010-09-27 21:11:13 PDT
Duplicated code for GURL => sadness.
Daniel Bates
Comment 6 2010-10-09 15:58:52 PDT
(In reply to comment #5) > Duplicated code for GURL => sadness. It seems the two implementations of copyParsedQueryTo() simply differ in their initialization of pos and end. Could we use a similar approach to ScriptControllerBase for KURL? That is, add a header and implementation file called KURLBase.h and KURLBase.cpp and extract the common code from the KURL and KURLGoogle files into a private function, say copyParsedQueryTo(ParsedURLParameters&, const UChar* startPosOfQueryString, const UChar* endPosOfQueryString). Then have KURL.h include KURLBase.h and have each implementation of the one-argument public variant of copyParsedQueryTo call the common private routine.
Daniel Bates
Comment 7 2010-10-09 16:28:04 PDT
Comment on attachment 69017 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=69017&action=review > WebCore/ChangeLog:29 > + * html/HTMLAnchorElement.cpp: > + (WebCore::HTMLAnchorElement::getParameter): > + * html/HTMLAnchorElement.h: > + * html/HTMLAnchorElement.idl: > + * page/Location.cpp: > + (WebCore::Location::getParameter): > + * page/Location.h: > + * page/Location.idl: > + * platform/KURL.cpp: > + (WebCore::KURL::copyParsedQueryTo): > + * platform/KURLGoogle.cpp: > + (WebCore::KURL::copyParsedQueryTo): > + * platform/KURL.h: For your consideration, I would suggest using the space to the right of the ':' in each entry above to remark on which methods were added by this patch. > LayoutTests/fast/dom/anchor-getParameter.html:31 > +for (var i = 0; i < cases.length; ++i) > + document.write('<a href="' + cases[i][0] + '">Link</a><br>'); Could we hide the output of this so that the text results don't show a long list of the word "Link"? For instance, we could enclose the output within a <div id="test-container"></div>, which we remove from the DOM before the of the <script>. If you see value in keeping such a list of hyperlinks, say for inspecting when running this test by hand, then could we just hide this output when the test is run with DRT? > LayoutTests/fast/dom/anchor-getParameter.html:38 > +</html> Is there a reason why you chose not to use fast/js/resources/js-test-pre.js, inline the expected results, and make this a PASS/FAIL test? I see the benefit of the verbose output (i.e. A => B) and we could make the PASS/FAIL message include similar verbose output so as to add context to the PASS/FAIL text results should a human read them.
Darin Adler
Comment 8 2010-10-13 13:16:24 PDT
Comment on attachment 69017 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=69017&action=review Thanks, looks good. I didn’t set commit-queue+ -- I’ll let you make the call on that. > WebCore/platform/KURL.cpp:624 > + const UChar* parameterBegin = pos; I’d prefer the noun “start” to the verb “begin” for the name here. > WebCore/platform/KURL.cpp:634 > + const UChar* nameBegin = parameterBegin; And here. > WebCore/platform/KURL.cpp:640 > + String name(nameBegin, equalSign - nameBegin); > + if (name.isEmpty()) > + continue; Might be slightly cleaner to do the empty check by checking if equalSign == nameBegin rather than constructing the string first. > WebCore/platform/KURL.h:63 > +typedef WTF::HashMap<String, String> ParsedURLParameters; No need for the WTF:: prefix here. > WebCore/platform/KURL.h:139 > + void copyParsedQueryTo(ParsedURLParameters& parameters) const; No need for the argument name “parameters” here. > WebCore/platform/KURLGoogle.cpp:556 > + String query = m_url.componentString(m_url.m_parsed.query); > + const UChar* pos = query.characters(); > + const UChar* end = query.characters() + query.length(); Too bad we have two copies of this given that almost all the code is identical. >> LayoutTests/fast/dom/anchor-getParameter.html:38 >> +</html> > > Is there a reason why you chose not to use fast/js/resources/js-test-pre.js, inline the expected results, and make this a PASS/FAIL test? I see the benefit of the verbose output (i.e. A => B) and we could make the PASS/FAIL message include similar verbose output so as to add context to the PASS/FAIL text results should a human read them. I agree with Daniel. I’d go further and say that a script-tests style test would be even better than the test here.
Adam Barth
Comment 9 2010-10-13 14:43:42 PDT
Thanks for the reviews. I've applied all of your suggestions except converting the test to a script-test. I'm not a big fan of the script-test framework, but I'll use it for these patches in the future.
Adam Barth
Comment 10 2010-10-13 14:44:57 PDT
Created attachment 70666 [details] Patch for landing
WebKit Commit Bot
Comment 11 2010-10-13 19:52:24 PDT
Comment on attachment 70666 [details] Patch for landing Rejecting patch 70666 from commit-queue. Failed to run "['./WebKitTools/Scripts/webkit-patch', '--status-host=queues.webkit.org', 'build-and-test', '--no-clean', '--no-update', '--test', '--quiet', '--non-interactive']" exit_code: 2 Last 500 characters of output: . Files=14, Tests=304, 3 wallclock secs ( 0.10 usr 0.07 sys + 0.65 cusr 0.20 csys = 1.02 CPU) Result: PASS Running build-dumprendertree Compiling Java tests make: Nothing to be done for `default'. Running tests from /Users/eseidel/Projects/CommitQueue/LayoutTests Testing 21249 test cases. fast/dom/Window/window-appendages-cleared.html -> failed Exiting early after 1 failures. 6976 tests run. 210.34s total testing time 6975 test cases (99%) succeeded 1 test case (<1%) had incorrect layout Full output: http://queues.webkit.org/results/4455017
Adam Barth
Comment 12 2010-10-14 01:02:35 PDT
WebKit Review Bot
Comment 13 2010-10-14 01:53:20 PDT
http://trac.webkit.org/changeset/69749 might have broken Qt Linux Release The following tests are not passing: fast/dom/Window/window-properties.html
Csaba Osztrogonác
Comment 14 2010-10-14 02:24:28 PDT
(In reply to comment #13) > http://trac.webkit.org/changeset/69749 might have broken Qt Linux Release > The following tests are not passing: > fast/dom/Window/window-properties.html Qt specific expected file updated: http://trac.webkit.org/changeset/69754
Adam Barth
Comment 15 2010-10-14 13:20:25 PDT
> Qt specific expected file updated: http://trac.webkit.org/changeset/69754 Thanks!
Note You need to log in before you can comment on or make changes to this bug.