BarProp.window.js (2314B)
1 function assert_barProps(barPropObjects, visible) { 2 let lastBarProp = undefined; 3 for (const currentBarProp of barPropObjects) { 4 assert_not_equals(currentBarProp, lastBarProp, "BarBrop objects of different properties are identical"); 5 assert_equals(currentBarProp.visible, visible, "a BarProp's visible is wrong"); 6 lastBarProp = currentBarProp; 7 } 8 } 9 10 function assert_identical_barProps(barProps, w, oldBarPropObjects, visible) { 11 barProps.map(val => w[val]).map((val, index) => { 12 assert_equals(val, oldBarPropObjects[index], "BarProp identity not preserved"); 13 }); 14 assert_barProps(oldBarPropObjects, visible); 15 } 16 17 async_test(t => { 18 const frame = document.body.appendChild(document.createElement("iframe")), 19 frameW = frame.contentWindow, 20 barProps = ["locationbar", "menubar", "personalbar", "scrollbars", "statusbar", "toolbar"], 21 barPropObjects = barProps.map(val => frameW[val]); 22 23 assert_barProps(barPropObjects, true); 24 frame.remove(); 25 assert_identical_barProps(barProps, frameW, barPropObjects, false); 26 t.step_timeout(() => { 27 assert_identical_barProps(barProps, frameW, barPropObjects, false); 28 t.done(); 29 }, 0); 30 }, "BarBrop objects of a nested Window"); 31 32 async_test(t => { 33 const openee = window.open("/common/blank.html"), 34 barProps = ["locationbar", "menubar", "personalbar", "scrollbars", "statusbar", "toolbar"], 35 barPropObjects = barProps.map(val => openee[val]); 36 37 // This is used to demonstrate that the Document is replaced while the global object (not the 38 // global this object) stays the same 39 openee.tiedToGlobalObject = openee.document; 40 41 assert_barProps(barPropObjects, true); 42 openee.onload = t.step_func(() => { 43 assert_own_property(openee, "tiedToGlobalObject"); 44 assert_not_equals(openee.tiedToGlobalObject, openee.document); 45 46 assert_identical_barProps(barProps, openee, barPropObjects, true); 47 48 openee.onpagehide = t.step_func(() => { 49 assert_identical_barProps(barProps, openee, barPropObjects, true); 50 t.step_timeout(() => { 51 assert_identical_barProps(barProps, openee, barPropObjects, false); 52 t.done(); 53 }, 0); 54 }); 55 56 openee.close(); 57 assert_identical_barProps(barProps, openee, barPropObjects, true); 58 }); 59 }, "BarProp objects of an auxiliary Window");