browser_basic_outofprocess.js (3660B)
1 /** 2 * Verify that the colors were set properly. This has the effect of 3 * verifying that the processes are assigned for child frames correctly. 4 */ 5 async function verifyBaseFrameStructure( 6 browsingContexts, 7 testname, 8 expectedHTML 9 ) { 10 function checkColorAndText(bc, desc, expectedColor, expectedText) { 11 return SpecialPowers.spawn( 12 bc, 13 [expectedColor, expectedText, desc], 14 (expectedColorChild, expectedTextChild, descChild) => { 15 Assert.equal( 16 content.document.documentElement.style.backgroundColor, 17 expectedColorChild, 18 descChild + " color" 19 ); 20 Assert.equal( 21 content.document.getElementById("insertPoint").innerHTML, 22 expectedTextChild, 23 descChild + " text" 24 ); 25 } 26 ); 27 } 28 29 let useOOPFrames = gFissionBrowser; 30 31 is( 32 browsingContexts.length, 33 TOTAL_FRAME_COUNT, 34 "correct number of browsing contexts" 35 ); 36 await checkColorAndText( 37 browsingContexts[0], 38 testname + " base", 39 "white", 40 expectedHTML.next().value 41 ); 42 await checkColorAndText( 43 browsingContexts[1], 44 testname + " frame 1", 45 useOOPFrames ? "seashell" : "white", 46 expectedHTML.next().value 47 ); 48 await checkColorAndText( 49 browsingContexts[2], 50 testname + " frame 1-1", 51 useOOPFrames ? "seashell" : "white", 52 expectedHTML.next().value 53 ); 54 await checkColorAndText( 55 browsingContexts[3], 56 testname + " frame 2", 57 useOOPFrames ? "lightcyan" : "white", 58 expectedHTML.next().value 59 ); 60 await checkColorAndText( 61 browsingContexts[4], 62 testname + " frame 2-1", 63 useOOPFrames ? "seashell" : "white", 64 expectedHTML.next().value 65 ); 66 await checkColorAndText( 67 browsingContexts[5], 68 testname + " frame 2-2", 69 useOOPFrames ? "lightcyan" : "white", 70 expectedHTML.next().value 71 ); 72 await checkColorAndText( 73 browsingContexts[6], 74 testname + " frame 2-3", 75 useOOPFrames ? "palegreen" : "white", 76 expectedHTML.next().value 77 ); 78 await checkColorAndText( 79 browsingContexts[7], 80 testname + " frame 2-4", 81 "white", 82 expectedHTML.next().value 83 ); 84 } 85 86 /** 87 * Test setting up all of the frames where a string of markup is passed 88 * to initChildFrames. 89 */ 90 add_task(async function test_subframes_string() { 91 let tab = await BrowserTestUtils.openNewForegroundTab( 92 gBrowser, 93 OOP_BASE_PAGE_URI 94 ); 95 96 const markup = "<p>Text</p>"; 97 98 let browser = tab.linkedBrowser; 99 let browsingContexts = await initChildFrames(browser, markup); 100 101 function* getExpectedHTML() { 102 for (let c = 1; c <= TOTAL_FRAME_COUNT; c++) { 103 yield markup; 104 } 105 ok(false, "Frame count does not match actual number of frames"); 106 } 107 await verifyBaseFrameStructure(browsingContexts, "string", getExpectedHTML()); 108 109 BrowserTestUtils.removeTab(tab); 110 }); 111 112 /** 113 * Test setting up all of the frames where a function that returns different markup 114 * is passed to initChildFrames. 115 */ 116 add_task(async function test_subframes_function() { 117 let tab = await BrowserTestUtils.openNewForegroundTab( 118 gBrowser, 119 OOP_BASE_PAGE_URI 120 ); 121 let browser = tab.linkedBrowser; 122 123 let counter = 0; 124 let browsingContexts = await initChildFrames(browser, function () { 125 return "<p>Text " + ++counter + "</p>"; 126 }); 127 128 is( 129 counter, 130 TOTAL_FRAME_COUNT, 131 "insert HTML function called the correct number of times" 132 ); 133 134 function* getExpectedHTML() { 135 for (let c = 1; c <= TOTAL_FRAME_COUNT; c++) { 136 yield "<p>Text " + c + "</p>"; 137 } 138 } 139 await verifyBaseFrameStructure( 140 browsingContexts, 141 "function", 142 getExpectedHTML() 143 ); 144 145 BrowserTestUtils.removeTab(tab); 146 });