Closed Bug 158598 Opened 22 years ago Closed 22 years ago

Save Page As fails on pages with no title, filename or URL e.g. JavaScript generated popup windows

Categories

(Core Graveyard :: File Handling, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: ed, Assigned: law)

References

()

Details

(Keywords: testcase)

Attachments

(2 files, 4 obsolete files)

From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1b) Gecko/20020721 BuildID: 2002072108 If I use JavaScript to create a new document by a call to window.open() without any arguments, this will create a new blank page in its own window; I can then use the DOM to add content to that page. If I then select File->Save Page As..., nothing happens. If, however, I use document.title to give the page a title, the Save Page As dialog will appear. Similarly, if I visit about:blank and select File->Save Page As..., nothing happens. Reproducible: Always Steps to Reproduce: 1.Visit about:blank or call window.open(); 2.Select File->Save Page As... Actual Results: Nothing happens in Navigator. The following error is generated in the JavaScript Console: Error: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIURI.host]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://communicator/content/contentAreaUtils.js :: getDefaultFileName :: line 662" data: no] Source File: chrome://communicator/content/contentAreaUtils.js Line: 662 Expected Results: Save As dialog should appear with some suitable filename (e.g. blank.html) I believe there are quite a few bugs out there which express symptoms of this bug.
This demonstrates the bug. The file itself will not kill Save Page As, as it has a URL or filename. It opens a window to about:blank, which kills Save Page As. It creates a document by window.open(), which kills Save Page As. It creates a document by window.open(), but then gives it a title by document.title; as a result, Save Page As succeeds.
Keywords: testcase
I see your problem. It looks like there are actually two problems: one, that trying to access the hostname gives an uncaught error, and two, there is nothing else for Mozilla to use. I made a patch that solves the error, and defaults to an empty file name (it will end up as .html). A different default file name would be nice, but that would have to be added by i18n.
file handling. Could we default the filename to "index" (no extension) please? And yes, please localize it.
Assignee: sgehani → law
Status: UNCONFIRMED → NEW
Component: XP Apps → File Handling
Ever confirmed: true
QA Contact: paw → sairuh
Where should the localized string be located? I'm not sure where to put it.
contentAreaCommands.properties; see the getStringBundle() function and its uses in contentAreaUtils.js
Attached patch Updated patch (obsolete) — Splinter Review
Here's the updated patch. With the patch, attempts at getting a filename for a document come in this order (copied from the function; parentheses added): 1) Use the name suggested by the HTTP headers 2) Use the actual file name, if present 3) Use the document title 4) Use the caller-provided name, if any 5) Use the host (crashed before patch; now in a try/catch) 6) Use the default file name (added by this patch; currently index) If everything above is correct, this patch is ready for review.
Attachment #92186 - Attachment is obsolete: true
Comment on attachment 92309 [details] [diff] [review] Updated patch One other thing, please... if the GetStringFromName throws an exception (because the localization does not provide that string), could you fall back to "index" in the js?
Attached patch Another update (obsolete) — Splinter Review
Fallback to "index" added
Attachment #92309 - Attachment is obsolete: true
Comment on attachment 92312 [details] [diff] [review] Another update put a semicolon after that last return statement, and sr=bzbarsky
Attachment #92312 - Flags: superreview+
Attached patch Update to Patch (obsolete) — Splinter Review
Attachment #92312 - Attachment is obsolete: true
*** Bug 120457 has been marked as a duplicate of this bug. ***
Blocks: 115634
*** Bug 131560 has been marked as a duplicate of this bug. ***
Attachment #92313 - Flags: superreview+
*** Bug 120457 has been marked as a duplicate of this bug. ***
Comment on attachment 92313 [details] [diff] [review] Update to Patch r=timeless for c++ we try to aim for 80 cols, for xul/js i try to aim for 100 cols (80 of course is still prefered, but recognized as impractical). personally I'd prefer for your comments to be one line above or below the affected statement. but that's me. thanks for the patch.
Attachment #92313 - Flags: review+
Attached patch Final PatchSplinter Review
The only change is to the comment layout, as requested by timeless. (No functionality change) timeless, will you handle checkin?
Attachment #92313 - Attachment is obsolete: true
Checked in on the trunk.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
using the test case, Save Page As provides a suggested filename for all 4 tests. verified fixed using 2002.09.19.08 comm trunk builds on all platforms.
Status: RESOLVED → VERIFIED
Hardware: PC → All
*** Bug 157198 has been marked as a duplicate of this bug. ***
Is Save Page As... still working for folks? I'm seeing something like it in 1.5. See bug 200741. Re. the attachment "4 pages - 2 fail, 2 work": for me all of them fail. (Had to enable pop-ups to get it to show the pages.) The changes that the patch made work - the filenames that Save Page As... offers (but fails) to save are correctly named, and a Save dialog box does pop up.
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: