Bug 148852

Summary: script.text should behave like script.textContent on setting
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: DOMAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, esprehn+autocc, gyuyoung.kim, kling, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
cdumez: review+, cdumez: commit-queue-
Patch for landing none

Description Ryosuke Niwa 2015-09-04 16:52:37 PDT
See https://html.spec.whatwg.org/multipage/scripting.html#dom-script-text

The setter implementation of HTMLScriptElement.prototype.text should be identical to that of textContent but it isn't.

This bug was found by the newly added test:
LayoutTests/http/tests/w3c/html/semantics/scripting-1/the-script-element/script-text.html
Comment 1 Andreas Kling 2016-08-27 09:21:00 PDT
Created attachment 287204 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2016-08-27 09:21:39 PDT
<rdar://problem/28044640>
Comment 3 Chris Dumez 2016-08-27 09:57:29 PDT
Comment on attachment 287204 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=287204&action=review

r=me with comment.

> Source/WebCore/html/HTMLScriptElement.cpp:85
> +    setTextContent(value, IGNORE_EXCEPTION);

I believe this cannot actually throw. If this is the case, then we should use ASSERT_NOT_EXCEPTION, not IGNORE_EXCEPTION. If it can actually throw, then we should use [SetterRaisesException] on the text attribute and relay the exception to the caller.
Comment 4 Andreas Kling 2016-08-27 10:02:15 PDT
Comment on attachment 287204 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=287204&action=review

>> Source/WebCore/html/HTMLScriptElement.cpp:85
>> +    setTextContent(value, IGNORE_EXCEPTION);
> 
> I believe this cannot actually throw. If this is the case, then we should use ASSERT_NOT_EXCEPTION, not IGNORE_EXCEPTION. If it can actually throw, then we should use [SetterRaisesException] on the text attribute and relay the exception to the caller.

Hmm. You are probably right about this. I suspect the same is also true for HTMLAnchorElement.text and HTMLTitleElement.text
Comment 5 Andreas Kling 2016-08-27 10:16:00 PDT
Created attachment 287205 [details]
Patch for landing
Comment 6 WebKit Commit Bot 2016-08-27 10:47:00 PDT
Comment on attachment 287205 [details]
Patch for landing

Clearing flags on attachment: 287205

Committed r205079: <http://trac.webkit.org/changeset/205079>
Comment 7 WebKit Commit Bot 2016-08-27 10:47:05 PDT
All reviewed patches have been landed.  Closing bug.