perturb.org expects to be able to get document.write() to imply a document.open() call when called from a script-inserted external script

RESOLVED FIXED

Status

RESOLVED FIXED
8 years ago
4 years ago

People

(Reporter: scott, Unassigned)

Tracking

Details

(Reporter)

Description

8 years ago
The bookmarklet provided here: http://www.perturb.org/images/easy_capture/ fails to run on the latest Firefox nightly. It runs on the current 3.6.x branch. If you navigate to a page with an <img> tag on it, and run that bookmarklet it's supposed to show you images to capture, but it doesn't.

Steps to recreate:

1) Navigate to a page with <img> tags like http://www.cnn.com/
2) Run that bookmarklet
3) Notice that nothing is displayed, and no JS errors are thrown in Firebug

Here is the bookmarklet for study

javascript:void(z=document.body.appendChild(document.createElement('script')));void(z.language='javascript');void(z.type='text/javascript');void(z.src='http://www.perturb.org/images/easy_capture/images.js.php');
This prints in the Web Console:

[17:08:24.379] A call to document.write() from an asynchronously-loaded external script was ignored. @ http://www.cnn.com/
This is documented here: https://developer.mozilla.org/en/html/element/script#Attributes

But even if I set async to false, I get the message. Bookmarklet with z.async=false:

javascript:void(z=document.body.appendChild(document.createElement('script')));void(z.async=false);void(z.language='javascript');void(z.type='text/javascript');void(z.src='http://www.perturb.org/images/easy_capture/images.js.php');
This is a side effect of write-neutralizing script-created external scripts. It's unfortunate that this bookmarklet breaks, but it would be worse to have random ad scripts around the Web break sites.

This should be fixable by making http://www.perturb.org/images/easy_capture/images.js.php call document.open() explicitly.
Assignee: general → nobody
Component: JavaScript Engine → HTML: Parser
QA Contact: general → parser
Assignee: nobody → english-us
Component: HTML: Parser → English US
Product: Core → Tech Evangelism
QA Contact: parser → english-us
Summary: Possible regression on javascript bookmarklet? → perturb.org expects to be able to get document.write() to imply a document.open() call when called from a script-inserted external script
(Reporter)

Comment 4

8 years ago
Should that script being doing?

document.open();
document.write();
document.close();

The docs (https://developer.mozilla.org/en/DOM/document.open) have an example where the open is AFTER the write? I'm not sure which is correct.
(In reply to comment #4)
> Should that script being doing?
> 
> document.open();
> document.write();
> document.close();

Yes.

> The docs (https://developer.mozilla.org/en/DOM/document.open) have an example
> where the open is AFTER the write? I'm not sure which is correct.

The example tries to illustrate that in that case, what was written by document.write() is blown away by the later document.open().
(Reporter)

Comment 6

8 years ago
Looks like Chrome 9 does the same thing (doesn't run). 

If I tweak the script to do an open, write, and then a close it looks like it works again.
Status: NEW → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED
Product: Tech Evangelism → Tech Evangelism Graveyard
You need to log in before you can comment on or make changes to this bug.