diff --git a/toolkit/mozapps/downloads/HelperAppDlg.jsm b/toolkit/mozapps/downloads/HelperAppDlg.jsm index 61861389a72a..529b7ec7db3e 100644 --- a/toolkit/mozapps/downloads/HelperAppDlg.jsm +++ b/toolkit/mozapps/downloads/HelperAppDlg.jsm @@ -1326,7 +1326,8 @@ nsUnknownContentTypeDialog.prototype = { false ) && DownloadIntegration.shouldViewDownloadInternally( - this.mLauncher.MIMEInfo.MIMEType + this.mLauncher.MIMEInfo.MIMEType, + primaryExtension ) ); }, diff --git a/uriloader/exthandler/tests/mochitest/browser.ini b/uriloader/exthandler/tests/mochitest/browser.ini index d326a0ae5f2a..684cb2dcc4b9 100644 --- a/uriloader/exthandler/tests/mochitest/browser.ini +++ b/uriloader/exthandler/tests/mochitest/browser.ini @@ -21,6 +21,8 @@ support-files = file_pdf_binary_octet_stream.pdf^headers^ file_txt_attachment_test.txt file_txt_attachment_test.txt^headers^ + file_xml_attachment_binary_octet_stream.xml + file_xml_attachment_binary_octet_stream.xml^headers^ file_xml_attachment_test.xml file_xml_attachment_test.xml^headers^ [browser_download_urlescape.js] diff --git a/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js b/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js index eb82604456c5..8113de23ce6d 100644 --- a/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js +++ b/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js @@ -451,30 +451,39 @@ add_task(async function test_check_open_with_external_then_internal() { */ add_task( async function test_internal_handler_hidden_with_viewable_internally_type() { - let dialogWindowPromise = BrowserTestUtils.domWindowOpenedAndLoaded(); - let loadingTab = await BrowserTestUtils.openNewForegroundTab( - gBrowser, - TEST_PATH + "file_xml_attachment_test.xml" - ); - let dialogWindow = await dialogWindowPromise; - is( - dialogWindow.location.href, - "chrome://mozapps/content/downloads/unknownContentType.xhtml", - "Should have seen the unknown content dialogWindow." - ); - let doc = dialogWindow.document; - let internalHandlerRadio = doc.querySelector("#handleInternally"); + for (let [file, checkDefault] of [ + // The default for binary/octet-stream is changed by the PDF tests above, + // this may change given bug 1659008, so I'm just ignoring the default for now. + ["file_xml_attachment_binary_octet_stream.xml", false], + ["file_xml_attachment_test.xml", true], + ]) { + let dialogWindowPromise = BrowserTestUtils.domWindowOpenedAndLoaded(); + let loadingTab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + TEST_PATH + file + ); + let dialogWindow = await dialogWindowPromise; + is( + dialogWindow.location.href, + "chrome://mozapps/content/downloads/unknownContentType.xhtml", + "Should have seen the unknown content dialogWindow." + ); + let doc = dialogWindow.document; + let internalHandlerRadio = doc.querySelector("#handleInternally"); - // Prevent racing with initialization of the dialog and make sure that - // the final state of the dialog has the correct visibility of the internal-handler option. - await waitForAcceptButtonToGetEnabled(doc); + // Prevent racing with initialization of the dialog and make sure that + // the final state of the dialog has the correct visibility of the internal-handler option. + await waitForAcceptButtonToGetEnabled(doc); - ok(!internalHandlerRadio.hidden, "The option should be visible for XML"); - ok(internalHandlerRadio.selected, "The option should be selected"); + ok(!internalHandlerRadio.hidden, "The option should be visible for XML"); + if (checkDefault) { + ok(internalHandlerRadio.selected, "The option should be selected"); + } - let dialog = doc.querySelector("#unknownContentType"); - dialog.cancelDialog(); - BrowserTestUtils.removeTab(loadingTab); + let dialog = doc.querySelector("#unknownContentType"); + dialog.cancelDialog(); + BrowserTestUtils.removeTab(loadingTab); + } } ); diff --git a/uriloader/exthandler/tests/mochitest/file_xml_attachment_binary_octet_stream.xml b/uriloader/exthandler/tests/mochitest/file_xml_attachment_binary_octet_stream.xml new file mode 100644 index 000000000000..3a5792586af8 --- /dev/null +++ b/uriloader/exthandler/tests/mochitest/file_xml_attachment_binary_octet_stream.xml @@ -0,0 +1,4 @@ + + + + diff --git a/uriloader/exthandler/tests/mochitest/file_xml_attachment_binary_octet_stream.xml^headers^ b/uriloader/exthandler/tests/mochitest/file_xml_attachment_binary_octet_stream.xml^headers^ new file mode 100644 index 000000000000..5bdc4448e8ad --- /dev/null +++ b/uriloader/exthandler/tests/mochitest/file_xml_attachment_binary_octet_stream.xml^headers^ @@ -0,0 +1,2 @@ +Content-Disposition: attachment +Content-Type: binary/octet-stream