Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8269115

WebView paste event contains old data

XMLWordPrintable

    • web
    • generic
    • generic

        A DESCRIPTION OF THE PROBLEM :
        When using copy & paste within the JavaFX WebView, the list in e.clipboardData.types gets longet with every paste.
        If a earlier copy-event contains "text/plain" and "text/html" data flavors and a following copy onle "text/plain", the next paste-event still contains the "text/html" flavor with data from the first copy-event.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1. Select some text of the example page within the JavaFX WebView and press Ctrl+C
        2. Press Ctrl+V - the webview displays that the pase-event contains "text/plain" and "text/html" data flavors with your selected text.
        3. Select and copy text from an application, which only delivers text/plain, for example notepad.
        4. Press Ctrl+V - the webview now displays some duplicate "text/plain" data flavors in the paste-event. The "text/html" still contains data from the first copy-event.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        After step 4 the example page should only display one "text/plane" data flavor with the content of the last copy-event.
        ACTUAL -
        After step 4 the example page displays multiple "text/plane" data flavors and an old "text/html" data flavor, which contains old data.

        ---------- BEGIN SOURCE ----------
        Load this html into a JavaFX WebView:
        <html>
        <head>
            <script>
                document.addEventListener('paste', e => {
                    let messages = [];
                    if (e.clipboardData.types) {
                        e.clipboardData.types.forEach(type => {
                            messages.push( type + ": " + e.clipboardData.getData(type));
                        });
                    }
                                    
        document.getElementById("clipboardData").innerHTML = messages.join("<br />");
                });
            </script>
        </head>
        <body>
        <b>This is a test of the clipboard. The content of the clipboard will be displayed below after pressing ctrl+v:</b>
        <div id="clipboardData"></div>
        <br/>
        <a href="https://evercoder.github.io/clipboard-inspector/">click here to get a better clipboard inspector</a>
        </body>
        </html>
        ---------- END SOURCE ----------

        FREQUENCY : always


              jbhaskar Jay Bhaskar
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: