1/** 2 * Copyright 2017 Google Inc. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17import expect from 'expect'; 18import { getTestState, describeChromeOnly } from './mocha-utils'; // eslint-disable-line import/extensions 19 20describeChromeOnly('OOPIF', function () { 21 /* We use a special browser for this test as we need the --site-per-process flag */ 22 let browser; 23 let context; 24 let page; 25 26 before(async () => { 27 const { puppeteer, defaultBrowserOptions } = getTestState(); 28 browser = await puppeteer.launch( 29 Object.assign({}, defaultBrowserOptions, { 30 args: (defaultBrowserOptions.args || []).concat(['--site-per-process']), 31 }) 32 ); 33 }); 34 35 beforeEach(async () => { 36 context = await browser.createIncognitoBrowserContext(); 37 page = await context.newPage(); 38 }); 39 40 afterEach(async () => { 41 await context.close(); 42 page = null; 43 context = null; 44 }); 45 46 after(async () => { 47 await browser.close(); 48 browser = null; 49 }); 50 xit('should report oopif frames', async () => { 51 const { server } = getTestState(); 52 53 await page.goto(server.PREFIX + '/dynamic-oopif.html'); 54 expect(oopifs(context).length).toBe(1); 55 expect(page.frames().length).toBe(2); 56 }); 57 it('should load oopif iframes with subresources and request interception', async () => { 58 const { server } = getTestState(); 59 60 await page.setRequestInterception(true); 61 page.on('request', (request) => request.continue()); 62 await page.goto(server.PREFIX + '/dynamic-oopif.html'); 63 expect(oopifs(context).length).toBe(1); 64 }); 65}); 66 67/** 68 * @param {!BrowserContext} context 69 */ 70function oopifs(context) { 71 return context 72 .targets() 73 .filter((target) => target._targetInfo.type === 'iframe'); 74} 75