Bug 146566 - REGRESSION (r178097): HTMLSelectElement.add(option, undefined) prepends option to the list of options; should append to the end of the list of options
Summary: REGRESSION (r178097): HTMLSelectElement.add(option, undefined) prepends optio...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P1 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar, Regression
Depends on: 139179
Blocks:
  Show dependency treegraph
 
Reported: 2015-07-02 17:41 PDT by Daniel Bates
Modified: 2015-07-03 20:57 PDT (History)
10 users (show)

See Also:


Attachments
Example (585 bytes, text/html)
2015-07-02 17:45 PDT, Daniel Bates
no flags Details
Patch (21.50 KB, patch)
2015-07-03 11:22 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (20.68 KB, patch)
2015-07-03 14:03 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-mavericks (535.31 KB, application/zip)
2015-07-03 14:42 PDT, Build Bot
no flags Details
Patch (21.56 KB, patch)
2015-07-03 14:44 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2015-07-02 17:41:32 PDT
Following the change made in bug #139179 (http://trac.webkit.org/changeset/178097), calling HTMLSelectElement.add(O, undefined) prepends O to the list of options where O is either an HTML option element or an HTML optgroup element. But it should append O to the end of the list of options.
Comment 1 Daniel Bates 2015-07-02 17:45:56 PDT
Created attachment 256056 [details]
Example
Comment 2 Radar WebKit Bug Importer 2015-07-02 17:49:42 PDT
<rdar://problem/21663919>
Comment 3 Chris Dumez 2015-07-02 20:18:57 PDT
Relevant specs:
https://html.spec.whatwg.org/multipage/forms.html#dom-select-add

which points to:
https://html.spec.whatwg.org/multipage/infrastructure.html#dom-htmloptionscollection-add

which says in this case to call the DOM insertBefore() method on the parent node, with element as the first argument and null (in our case) as the second argument.

https://dom.spec.whatwg.org/#dom-node-insertbefore
->
https://dom.spec.whatwg.org/#concept-node-insert

"
For each newNode in nodes, in tree order, run these substeps:
1. Insert newNode into parent before child or at the end of parent if child is null.
2. Run the insertion steps with newNode.
"

Ok, so even though it is hard to follow, the spec does say to insert "at the end of parent if child is null".
Comment 4 Chris Dumez 2015-07-03 11:22:48 PDT
Created attachment 256114 [details]
Patch
Comment 5 Chris Dumez 2015-07-03 14:03:32 PDT
Created attachment 256120 [details]
Patch
Comment 6 Build Bot 2015-07-03 14:42:47 PDT
Comment on attachment 256120 [details]
Patch

Attachment 256120 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/4714810553925632

New failing tests:
fast/dom/HTMLSelectElement/add.html
Comment 7 Build Bot 2015-07-03 14:42:50 PDT
Created attachment 256122 [details]
Archive of layout-test-results from ews102 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 8 Chris Dumez 2015-07-03 14:44:03 PDT
Created attachment 256123 [details]
Patch
Comment 9 WebKit Commit Bot 2015-07-03 20:57:17 PDT
Comment on attachment 256123 [details]
Patch

Clearing flags on attachment: 256123

Committed r186275: <http://trac.webkit.org/changeset/186275>
Comment 10 WebKit Commit Bot 2015-07-03 20:57:22 PDT
All reviewed patches have been landed.  Closing bug.