browser_jsonview_iframes_ignored.js (1262B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const TEST_JSON_URL = URL_ROOT + "doc_with_json_in_iframe.html"; 7 8 add_task(async function () { 9 info("Test JSON view is disabled for iframes"); 10 11 await addTab(TEST_JSON_URL); 12 13 // Wait for JSONView to have a chance to load. 14 // As we expect it to not load, we can't listen to any particular event. 15 await wait(1000); 16 17 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () { 18 const frameWin = content.frames[0]; 19 ok( 20 !frameWin.wrappedJSObject.JSONView, 21 "JSONView object isn't instantiated in the iframe" 22 ); 23 is( 24 frameWin.document.contentType, 25 "application/json", 26 "The mime type is json and not jsonview one" 27 ); 28 // When JSON file is displayed as-is, it is within a made up HTML document 29 // where the JSON text is put as child text element of a <pre> element. 30 ok( 31 frameWin.document.querySelector("pre"), 32 "There is a <pre> element in plain text html document" 33 ); 34 // That made up HTML doesn't include any <div> element. 35 ok( 36 !frameWin.document.querySelector("div"), 37 "But there is no <div> coming from JSONView" 38 ); 39 }); 40 });