From 57ade91b4caf0a0bdde85f50194bd8d56d1c2d54 Mon Sep 17 00:00:00 2001 From: Paolo Amadini Date: Tue, 8 Jun 2010 03:15:00 -0400 Subject: [PATCH] Bug 485196 - Web page generated by POST is retried as GET when Save Frame As used, and the page is no longer in the cache. r=smaug, r=gavin --HG-- rename : toolkit/content/tests/browser/browser_bug471962.js => toolkit/content/tests/browser/browser_save_resend_postdata.js extra : rebase_source : e985407c54fcd0f138bb7c1bf350356aa4dec2de --- toolkit/content/contentAreaUtils.js | 18 +++++++++++------- toolkit/content/tests/browser/Makefile.in | 2 +- ...1962.js => browser_save_resend_postdata.js} | 13 ++++++++++--- 3 files changed, 22 insertions(+), 11 deletions(-) rename toolkit/content/tests/browser/{browser_bug471962.js => browser_save_resend_postdata.js} (92%) diff --git a/toolkit/content/contentAreaUtils.js b/toolkit/content/contentAreaUtils.js index 18ad112293ba..fadbb5ef9ea0 100644 --- a/toolkit/content/contentAreaUtils.js +++ b/toolkit/content/contentAreaUtils.js @@ -750,13 +750,17 @@ function appendFiltersForContentType(aFilePicker, aContentType, aFileExtension, function getPostData(aDocument) { try { - var sessionHistory = aDocument.defaultView - .QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIWebNavigation) - .sessionHistory; - return sessionHistory.getEntryAtIndex(sessionHistory.index, false) - .QueryInterface(Components.interfaces.nsISHEntry) - .postData; + // Find the session history entry corresponding to the given document. In + // the current implementation, nsIWebPageDescriptor.currentDescriptor always + // returns a session history entry. + var sessionHistoryEntry = + aDocument.defaultView + .QueryInterface(Components.interfaces.nsIInterfaceRequestor) + .getInterface(Components.interfaces.nsIWebNavigation) + .QueryInterface(Components.interfaces.nsIWebPageDescriptor) + .currentDescriptor + .QueryInterface(Components.interfaces.nsISHEntry); + return sessionHistoryEntry.postData; } catch (e) { } diff --git a/toolkit/content/tests/browser/Makefile.in b/toolkit/content/tests/browser/Makefile.in index 6fc08a1c206c..0b85844d462e 100644 --- a/toolkit/content/tests/browser/Makefile.in +++ b/toolkit/content/tests/browser/Makefile.in @@ -51,9 +51,9 @@ DIRS = \ include $(topsrcdir)/config/rules.mk _BROWSER_TEST_FILES = \ - browser_bug471962.js \ browser_keyevents_during_autoscrolling.js \ browser_bug295977_autoscroll_overflow.js \ + browser_save_resend_postdata.js \ browser_Services.js \ $(NULL) diff --git a/toolkit/content/tests/browser/browser_bug471962.js b/toolkit/content/tests/browser/browser_save_resend_postdata.js similarity index 92% rename from toolkit/content/tests/browser/browser_bug471962.js rename to toolkit/content/tests/browser/browser_save_resend_postdata.js index 18d74a3b9bb8..b9fbe3b18548 100644 --- a/toolkit/content/tests/browser/browser_bug471962.js +++ b/toolkit/content/tests/browser/browser_save_resend_postdata.js @@ -38,6 +38,10 @@ * Test for bug 471962 : * When saving an inner frame as file only, the POST data of the outer page is * sent to the address of the inner page. + * + * Test for bug 485196 : + * Web page generated by POST is retried as GET when Save Frame As used, and the + * page is no longer in the cache. */ function test() { @@ -121,10 +125,13 @@ function test() { // Read the entire saved file. var fileContents = readShortFile(mockFilePickerResults.selectedFile); - // Check if outer POST data is found. - const searchPattern = "inputfield=outer"; - ok(fileContents.indexOf(searchPattern) === -1, + // Check if outer POST data is found (bug 471962). + ok(fileContents.indexOf("inputfield=outer") === -1, "The saved inner frame does not contain outer POST data"); + + // Check if inner POST data is found (bug 485196). + ok(fileContents.indexOf("inputfield=inner") > -1, + "The saved inner frame was generated using the correct POST data"); } finally { // Clean up the saved file.