browser_jsonview_multipart_response.js (1289B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Check that the JSON Viewer won't be loaded for mulipart responses and that the JSON 7 // file will be downloaded instead. 8 9 const TEST_MULTIPART_URL = URL_ROOT_SSL + "json_multipart.sjs"; 10 11 add_task(async function test_json_in_multipart_response() { 12 const onDownload = waitUntilDownload(); 13 const tab = await addTab(TEST_MULTIPART_URL, { waitForLoad: false }); 14 15 info("Await for download to be done"); 16 const filePath = await onDownload; 17 ok(!!filePath, "JSON file was downloaded"); 18 19 info("Clear downloaded file"); 20 await resetDownloads(); 21 22 // The multipart response waits a bit before sending the HTML part, let's wait for a bit 23 // so the response would have the time to settle. 24 await wait(2000); 25 26 info("Check that tab doesn't get the resource://devtools origin"); 27 await ContentTask.spawn(tab.linkedBrowser, [], async function () { 28 // The origin is "null", but it may be example.org if we weren't throwing JSON Converter. 29 Assert.notEqual( 30 content.origin, 31 "resource://devtools", 32 "The second document within this mixed replace request isn't gaining JSON Viewer origin" 33 ); 34 }); 35 36 BrowserTestUtils.removeTab(tab); 37 });