Perma /webdriver/tests/element_clear/clear.py | test_designmode - AssertionError: assert '<br>' == ''
Categories
(Remote Protocol :: Marionette, defect, P5)
Tracking
(Not tracked)
People
(Reporter: intermittent-bug-filer, Unassigned)
References
(Depends on 1 open bug)
Details
(4 keywords)
Filed by: hskupin [at] mozilla.com
Parsed log: https://treeherder.mozilla.org/logviewer.html#?job_id=259553433&repo=try
Full log: https://queue.taskcluster.net/v1/task/E8h06VnEThaonCF7NlyEdw/runs/0/artifacts/public/logs/live_backing.log
This is based on the merge from bug 1565646, and would need a fix in Marionette which simply replaces the <br>
with an empty string. For now I assume this merge commit will mark the test as expected fail, so lets wait until that landed on central.
Updated•5 years ago
|
Comment 1•5 years ago
|
||
Marionette sets the innerHTML
of the editing host to an empty string:
https://searchfox.org/mozilla-central/rev/c7e8bc4996f979e5876b33afae3de3b1ab4f3ae1/testing/marionette/interaction.js#356
My guess is that this problem is at the DOM level,
where no content implies <br>
in Gecko.
Comment 2•5 years ago
|
||
I'm sorry that I merged this PR, and as it looks like it's not only Firefox adding a <br>
when clearing the editable content but also Chrome, and Safari. I would say we get the PR (https://github.com/web-platform-tests/wpt/pull/17809) backed-out?
I don't have the repo so I cannot do it my own. Andreas, could you help with it please?
Comment 3•5 years ago
|
||
So if I understand correctly, you are saying this is a spec issue?
(I see the patch got reverted in https://github.com/web-platform-tests/wpt/pull/18421,
so clearing my needinfo.)
Comment 4•5 years ago
•
|
||
Maybe. It would need further investigation. There is https://github.com/web-platform-tests/wpt/pull/18470 now.
Comment 5•5 years ago
|
||
Once bug 1573878 gets merged it will be no longer a problem.
Comment 6•5 years ago
|
||
Actually I've made a mistake when checking this with Chrome and Safari. I cleared the contenteditable element by hand, and not by setting its innerHTML
value to an empty string. :/ When doing correctly Chrome indeed doesn't return a <br>
, but ``.
Test case: data:text/html;content,<html><body contentEditable=true>foo</body></html>
Steps:
- Open the dev tools inspector and select
Use in Console
for the body element - Run
temp0.innerHTML = ""
As you can see the content got replaced with <br>
.
Interestingly there is no <br>
node added when running the same steps with an inline element:
Test case: data:text/html;content,<html><body><span contentEditable=true>foo</span</body></html>
Olli, is there a spec which describes the correct behavior? Is it Firefox which is broken here, or all the other browsers?
Comment 7•5 years ago
|
||
Unfortunately there is no spec for contenteditable. So browsers do whatever they happen to do.
Comment 8•5 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #7)
Unfortunately there is no spec for contenteditable. So browsers do whatever they happen to do.
Given that all other browsers [1] keep the empty innerHTML
value, and only Firefox replaces it with <br>
, shouldn't we just drop our behavior and also keep it an empty value? It would help us for cross-browser compatibility even with no spec for contenteditable being present yet?
Comment 9•5 years ago
•
|
||
Maybe, or probably, but that means someone reverse-engineering what other browsers do with contentEditable and write a spec. So far that hasn't happened - it isn't exactly a trivial task.
Comment 10•5 years ago
|
||
Ok, so I wonder what we should do with this particular test. Maybe we should get the original patch re-landed, and mark the test as expected fail? Anything else would require a WebDriver spec change, or munging with the value, which means we cannot correctly detect an empty innerHTML value vs. a real line break. Andreas, what do you think?
Comment 11•5 years ago
|
||
We shouldn’t re-land the original patch, because that just replaces
<br>
with an empty string. Going by what smaug said earlier, the
WebDriver conformance test suite needs to accept both behaviours
because they’re equally correct.
This means we should probably accept
https://github.com/web-platform-tests/wpt/pull/18470 as a substitute.
Comment 12•5 years ago
|
||
(In reply to Henrik Skupin (:whimboo) [⌚️UTC+2] from comment #8)
(In reply to Olli Pettay [:smaug] from comment #7)
Unfortunately there is no spec for contenteditable. So browsers do whatever they happen to do.
Given that all other browsers [1] keep the empty
innerHTML
value, and only Firefox replaces it with<br>
, shouldn't we just drop our behavior and also keep it an empty value?
We probably should, in fact. This node used to be created internally (here) because we were unable to place carets inside empty block elements which would have zero height, as the height of the caret used to depend on its containing element. However we fixed that problem many years ago, and ever since then we were not aware of other use cases for this node (besides possibly code somewhere in the tree which depends on its existence.) When I owned the Editor module I had an item on my long term wish list to get rid of this element.
I believe that in order to fix this bug, we should fix Gecko to remove the padding BR element for empty editors...
We have bug 503838 open on this, FWIW.
Comment 13•5 years ago
|
||
Well, there is a remaining issue to remove the padding <br>
for the empty editor.
- Load
data:text/html,<div contenteditable>a</div>
- Remove the "a"
Chrome keeps one-line height for the <div> so that users can set focus with pointing device. However, if we'll stop creating the padding <br>
, the <div>
becomes 0 height. See bug 1098151.
Comment 14•5 years ago
|
||
I cannot see that with Chrome. When I press backspace once, and then blur the div by clicking somewhere outside the contenteditable the innerHTML
property shows as empty via dev tools. Only when I hit Return it will add the new line for sure.
But our specific case here is that directly setting innerHTML
to an empty string, results in <br>
, which is a behavior no other browser shows. I cannot say how this is related to when the user clears the content manually.
Comment 15•5 years ago
|
||
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900)(no pain of the broken bone, but the corset blocks me to concentrate) from comment #13)
Well, there is a remaining issue to remove the padding
<br>
for the empty editor.
- Load
data:text/html,<div contenteditable>a</div>
- Remove the "a"
Chrome keeps one-line height for the <div> so that users can set focus with pointing device. However, if we'll stop creating the padding
<br>
, the<div>
becomes 0 height. See bug 1098151.
OK, this makes sense to me. I wonder if there are any other cases which we also need to consider (e.g. with writing modes, etc...)
Comment 16•2 years ago
|
||
The test is no longer marked as failing. So I assume that we can just close the bug.
Comment 17•1 year ago
|
||
Moving bug to Remote Protocol::Marionette component per bug 1815831.
Description
•