Closed Bug 1535392 Opened 7 years ago Closed 7 years ago

<script style="display: block;"> tag disallow to copy content

Categories

(Core :: DOM: Serializers, defect, P3)

65 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: stack, Assigned: MatsPalmgren_bugz)

Details

(4 keywords)

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0

Steps to reproduce:

<!doctype html>
<html lang="en">
<head>
  <title>Attempt to emulate depricated XMP tag</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <style>
    script[type="text/plain"] {
      display: block;
      width: 100%;
      white-space: pre;
      box-sizing: border-box;
      user-select:text !important;
    }
  </style>
</head>

<body>

<script type="text/plain" readonly>
  Try to select then copy and paste me somewhere else ...
    and you will fail...
      WITH FireFox ONLY !!!
</script>

</body>
</html>

Actual results:

<xmp> tag is deprecated and as replacement it is advised to use <script type="text/plain"> tag instead to allow to put there content that includes html tags.

If one would attempt to select and copy content inside <script> tag then firefox allows to select and copy content but if you would try to paste copied content to text editor - it will return nothing.

Expected results:

It must work as it is in any major browsers (it even works in IE11) - allows to copy/paste content from <script> tag.

Keywords: html5
OS: Unspecified → All
Hardware: Unspecified → All
Summary: `<script type="text/plain">` tag disallow to copy content → <script type="text/plain"> tag disallow to copy content
Attached file reduced testcase.html

Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0
20190313100914

(In reply to Alexander J from comment #0)

<xmp> tag is deprecated and as replacement it is advised to use <script type="text/plain"> tag instead

MDN recommends using <pre> or <code> or some other element and applying a monospace font to it. You still have to escape < as &lt;
https://developer.mozilla.org/docs/Web/HTML/Element/xmp

It must work as it is in any major browsers

I suppose I'll confirm this since it works in other browsers, but I don't know if it's actually valid. Much of the supplied testcase is unnecessary; here's a reduced version.

Status: UNCONFIRMED → NEW
Has STR: --- → yes
Component: Untriaged → DOM: Core & HTML
Ever confirmed: true
Product: Firefox → Core
Summary: <script type="text/plain"> tag disallow to copy content → <script style="display: block;"> tag disallow to copy content

Thank you for your time you spent to take a look on this issue !

(In reply to Gingerbread Man from comment #1)

(In reply to Alexander J from comment #0)

<xmp> tag is deprecated and as replacement it is advised to use <script type="text/plain"> tag instead

MDN recommends using <pre> or <code> or some other element and applying a monospace font to it. You still have to escape < as &lt;
https://developer.mozilla.org/docs/Web/HTML/Element/xmp

It is really recommendation, it isn't a rule and there are a lot of cases when one need to display raw content, so users can simply copy and use raw content in perfectly legal tag

<script type="text/plain"> raw content, such as <p>tag</p></script>

There no exact replacement for <xmp> tag yet except the only one I showed, but if one would check search engines, there a lot of requests to use its functionality - display raw content without converting some characters to html entities.

It must work as it is in any major browsers

I suppose I'll confirm this since it works in other browsers, but I don't know if it's actually valid. Much of the supplied testcase is unnecessary; here's a reduced version.

According to HTML5, it perfectly legal to use <script type="media_type">, so I really don't understand why it shouldn't be valid, especially it works in all major nowadays browsers. The only difference in behavior to compare to other browsers is that Firefox allows to select and copy content, but for some strange reason, the only Firefox copy nothing, which looks like a clear bug.

Component: DOM: Core & HTML → Serializers
Priority: -- → P3
Assignee: nobody → mats
Status: NEW → ASSIGNED
Pushed by mpalmgren@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/413af5837faf <style> and <script> elements should be included in Selection.toString() unless they have CSS 'display:none'. r=smaug
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/16004 for changes under testing/web-platform/tests
Upstream PR was closed without merging
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: