On text/plain page, document.body.innerHTML='' acts strange.

RESOLVED WORKSFORME

Status

()

RESOLVED WORKSFORME
11 years ago
a year ago

People

(Reporter: BijuMailList, Unassigned)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

11 years ago
javascript:document.body.innerHTML='';void(0);

Above bookmarklet can be used to clear content of the page.
It works fine on an HTML page.

But on a page with mime-type:text/plain
It leaves "<HTML><BODY>"


Steps:
1. copy bookmarklet 
javascript:document.body.innerHTML='';void(0);

2. goto 
http://en.wikipedia.org/robots.txt

3. paste bookmarklet on location bar

4. press enter key, you see "<HTML><BODY>"

5. go to an html page

6. paste bookmarklet on location bar

7. press enter key, you see blank page

Updated

11 years ago
Summary: on text page document.body.innerHTML='' acts strange. → On text/plain page, document.body.innerHTML='' acts strange.
createContextualFragment assumes it's actually going to be parsed as markup.  We should probably make innerHTML throw in documents that are nsHTMLDocument but not text/html.
Component: DOM → DOM: Mozilla Extensions
Perhaps we should just blacklist text/plain instead of whitelisting both text/html and */*xml* (or however you describe the millions of XHTML content types).
Created attachment 281031 [details] [diff] [review]
So like this
Assignee: nobody → mrbkap
Status: NEW → ASSIGNED
Attachment #281031 - Flags: review?(bzbarsky)
> Perhaps we should just blacklist text/plain

And also all types handled like text/plain:

 91   "text/plain",
 92   "text/css",
 93   "text/javascript",
 94   "text/ecmascript",
 95   "application/javascript",
 96   "application/ecmascript",
 97   "application/x-javascript",

And also all image types and all plug-in types and anything else that creates a synthetic HTML document.

I really do think what I suggested in comment 1 is the way to go.
Note that if the blacklisting were in CreateContextualFragment it would be trivial to limit to non-HTML HTMLDocuments.
Comment on attachment 281031 [details] [diff] [review]
So like this

See comment 4
Attachment #281031 - Flags: review?(bzbarsky) → review-

Updated

9 years ago
Assignee: mrbkap → nobody
This is a mass change. Every comment has "assigned-to-new" in it.

I didn't look through the bugs, so I'm sorry if I change a bug which shouldn't be changed. But I guess these bugs are just bugs that were once assigned and people forgot to change the Status back when unassigning.
Status: ASSIGNED → NEW
(Assignee)

Updated

6 years ago
Component: DOM: Mozilla Extensions → DOM
Product: Core → Core

Comment 8

a year ago
This seems to work fine these days. And I don't think we need to change how the API works based on the document content type.
Status: NEW → RESOLVED
Last Resolved: a year ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.