addIframe-srcdoc.window.js (1136B)
1 // META: title=RemoteContextWrapper addIframe with srcdoc 2 // META: script=/common/dispatcher/dispatcher.js 3 // META: script=/common/get-host-info.sub.js 4 // META: script=/common/utils.js 5 // META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js 6 // META: script=./resources/test-helper.js 7 8 'use strict'; 9 10 // This tests that arguments passed to the constructor are respected. 11 promise_test(async t => { 12 const rcHelper = new RemoteContextHelper(); 13 14 const main = await rcHelper.addWindow(); 15 16 const iframe = await main.addIframeSrcdoc( 17 /*extraConfig=*/ {scripts: ['./resources/test-script.js']}, 18 /*attributes=*/ {id: 'test-id'}, 19 ); 20 21 await assertSimplestScriptRuns(iframe); 22 await assertFunctionRuns(iframe, () => testFunction(), 'testFunction exists'); 23 24 const [id, src, srcdoc] = await main.executeScript(() => { 25 const iframe = document.getElementById('test-id'); 26 return [iframe.id, iframe.src, iframe.srcdoc]; 27 }); 28 assert_equals(id, 'test-id', 'verify id'); 29 assert_equals(src, '', 'verify src'); 30 assert_greater_than(srcdoc.length, 0, 'verify srcdoc'); 31 });