Closed Bug 1131094 Opened 9 years ago Closed 9 years ago

window.open() behaving strangely when opening PDF files

Categories

(Firefox :: Untriaged, defect)

35 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: cito, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

Attached file test.html (obsolete) —
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0
Build ID: 20150122214805

Steps to reproduce:

Started Firefox 35.0.1 on Windows 7 64 bit.

Loaded the attached test.html file, which opens an arbitrary PDF file (called test.pdf) in a window created with window.open() after clicking a link, in two different manners.

The first link ("onestep") loads the PDF file directly in the window.open() command. The second link ("twostep") first opens an empty window with window.open() and then loads the PDF into that window by setting the location property of the window.


Actual results:

In the first case, an empty browser window opens, but then immediately closes again and the PDF is not displayed embedded in the opened browser window, but in a PDF viewer window.

In the second case, the empty window opens, then the PDF is displayed not in the browser window, but in another window of the PDF viewer, and the empty window stays open.


Expected results:

I would expect that the PDF is displayed embedded in the browser window opened with window.open(), not in a PDF viewer window. This is what happens in the current version of the other browsers MSIE 11, Chrome 40, Opera 27.

Also, I would expect that at least the two different ways of loading the PDF into the browser window would behave the same, i.e. the empty browser window either always closes or always stays open, but I prefer that it's closed in both cases.
Comment on attachment 8561419 [details]
test.html

<!DOCTYPE html>
<html>
<head>
<script>
var pdf='http://stlab.adobe.com/wiki/images/d/d3/Test.pdf';
function onestep() {
  window.open(pdf, 'test', 'height=400,width=200');
  return false;
}
function twostep() {
  w = window.open('', 'test', 'height=400,width=200');
  w.location = pdf;
  return false;
}
</script>
</head>
<body>
<h1>Test<h1>
<h2><a href="loaded-if-no-javascript.pdf" onclick="return onestep()">onestep</a></h2>
<h2><a href="loaded-if-no-javascript.pdf" onclick="return twostep()">twostep</a></h2>
</body>
</html>
Comment on attachment 8561419 [details]
test.html

<!DOCTYPE html>
<html>
<head>
<script>
var pdf='http://stlab.adobe.com/wiki/images/d/d3/Test.pdf';
function onestep() {
  window.open(pdf, 'test', 'height=400,width=200');
  return false;
}
function twostep() {
  w = window.open('', 'test', 'height=400,width=200');
  w.location = pdf;
  return false;
}
</script>
</head>
<body>
<h1>Test<h1>
<h2><a href="loaded-if-no-javascript.pdf" onclick="return onestep()">onestep</a></h2>
<h2><a href="loaded-if-no-javascript.pdf" onclick="return twostep()">twostep</a></h2>
</body>
</html>
Attached file Test HTML file
Attachment #8561419 - Attachment is obsolete: true
The last comments have been entered accidentally, please ignore them, unfortunately Bugzilla does not allow me to delete them.
Just a some background why it's sometimes necessary to load the PDF in 2 steps (1. open empty window, 2. set location) instead of 1 step (open window with location): The reason is that you need to open the window in the click event function because otherwise the popup blocker inhibits it. On the other hand, before opening the PDF you might want to execute something like submitting a form to set certain parameters for the PDF. PDF can then only be opened after that form is submitted, in some callback function, not in the original click event.
I should have also mentioned that I refer to the case where Firefox has been configured to use an external PDF viewer.
Closing this, because I messed things up a bit, will reopen a clean ticket.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → INVALID
This is now bug #1133062.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: