Bug 206360 - [GTK] 'insertHTML' command influenced by local style and inconsistent
Summary: [GTK] 'insertHTML' command influenced by local style and inconsistent
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-16 09:38 PST by Milan Crha
Modified: 2020-01-16 09:39 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Crha 2020-01-16 09:38:44 PST
The 'insertHTML' command is unreliable, it can strip content of the inserted HTML data based on the current document style, which is an error, from my point of view. Furthermore, it doesn't do that always, only the second (and following) time(s).

Steps:
a) run: MiniBrowser --editor-mode
b) open the web inspector and execute these commands in this order in the JavaScript console:

   document.documentElement.innerHTML = "<head><style>span.xxx { display:none;}</style></head><body><div><br></div></body>";
   document.getSelection().setPosition(document.body.firstElementChild, 1);
   document.execCommand("insertHTML", false, "<span class='yyy'><span class='zzz'>zzz</span><span class='xxx'>xxx</span></span>OOO");
   document.execCommand("insertHTML", false, "<span class='yyy'><span class='zzz'>zzz</span><span class='xxx'>xxx</span></span>OOO");

c) switch to the Elements tab and observer the structure under <body>.

Note I called 'insertHTML' twice with the same HTML data, thus I expect to see two same HTML code being inserted (in this case exactly the same HTML as entered in the command), but it shows this instead:

   <body>
      <div>
         <span class="yyy">
            <span class="zzz">zzz</span>
            <span class="xxx">xxx</span>
         </span>
         "OOO"
         <span class="zzz">zzz</span>
         "OOO"
      </div>
   </body>

Thus, from the second call only the "zzz" and "OOO" left, even it should be enclosed in "yyy" and have the "xxx" there as well.

When I remove the <style> from the <head> it behaves as expected, thus it seems like some optimization/normalization had been applied, causing this error.

I expect:
1) to have 'insertHTML' command behave consistently (should insert the same data, when the same HTML is passed in);
2) should not be influenced by currently active CSS rules.

For the record, this is what I expect to see in HTML structure:

   <body>
      <div>
         <span class="yyy">
            <span class="zzz">zzz</span>
            <span class="xxx">xxx</span>
         </span>
         "OOO"
         <span class="yyy">
            <span class="zzz">zzz</span>
            <span class="xxx">xxx</span>
         </span>
         "OOO"
      </div>
   </body>