blob: e1548d06c4609ee884afcfaf0526855f56641d6e [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
runTests([
// Open a page that loads a slow same-origin frame in it and remove the frame.
function loadTabWithSlowFrameAndRemoveFrame() {
const hostname = 'slow-child-frame-same-origin-remove-frame';
const url = getSlowURL(hostname);
const mainUrl = getPageWithFrame(url, hostname);
expect([
{ label: 'onBeforeRequest',
event: 'onBeforeRequest',
details: {
type: 'sub_frame',
url,
frameId: 1,
parentFrameId: 0,
frameUrl: url,
}
},
{ label: 'onBeforeSendHeaders',
event: 'onBeforeSendHeaders',
details: {
type: 'sub_frame',
url,
frameId: 1,
parentFrameId: 0,
},
},
{ label: 'onSendHeaders',
event: 'onSendHeaders',
details: {
type: 'sub_frame',
url,
frameId: 1,
parentFrameId: 0,
},
},
{ label: 'onErrorOccurred',
event: 'onErrorOccurred',
details: {
type: 'sub_frame',
url,
frameId: 1,
parentFrameId: 0,
fromCache: false,
error: 'net::ERR_ABORTED',
},
}],
[['onBeforeRequest', 'onBeforeSendHeaders', 'onSendHeaders',
'onErrorOccurred']],
{
urls: ['<all_urls>'],
types: ['sub_frame'],
});
waitUntilSendHeaders('sub_frame', url, function() {
// Cancels load and triggers onErrorOccurred.
chrome.tabs.executeScript(tabId, {
code: 'document.querySelector("iframe").remove();',
});
});
chrome.tabs.update(tabId, {url: mainUrl});
},
// Now reload the page (so that the frame appears again) and remove the tab.
// The expectations are identical to the previous test.
function openTabWithSlowFrameAndRemoveTab() {
const hostname = 'slow-child-frame-same-origin-remove-tab';
const url = getSlowURL(hostname);
const mainUrl = getPageWithFrame(url, hostname);
expect([
{ label: 'onBeforeRequest',
event: 'onBeforeRequest',
details: {
type: 'sub_frame',
url,
frameId: 1,
parentFrameId: 0,
frameUrl: url,
}
},
{ label: 'onBeforeSendHeaders',
event: 'onBeforeSendHeaders',
details: {
type: 'sub_frame',
url,
frameId: 1,
parentFrameId: 0,
},
},
{ label: 'onSendHeaders',
event: 'onSendHeaders',
details: {
type: 'sub_frame',
url,
frameId: 1,
parentFrameId: 0,
},
},
{ label: 'onErrorOccurred',
event: 'onErrorOccurred',
details: {
type: 'sub_frame',
url,
frameId: 1,
parentFrameId: 0,
fromCache: false,
error: 'net::ERR_ABORTED',
},
}],
[['onBeforeRequest', 'onBeforeSendHeaders', 'onSendHeaders',
'onErrorOccurred']],
{
urls: ['<all_urls>'],
types: ['sub_frame'],
});
var callbackDone = chrome.test.callbackAdded();
waitUntilSendHeaders('sub_frame', url, function() {
// Cancels load and triggers onErrorOccurred.
chrome.tabs.remove(tabId, callbackDone);
});
chrome.tabs.update(tabId, {url: mainUrl});
},
]);