// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const scriptUrl = '_test_resources/api_test/webnavigation/framework.js';
let loadScript = chrome.test.loadScript(scriptUrl);
loadScript.then(async function() {
let tab = await promise(chrome.tabs.create, {"url": "about:blank"});
let config = await promise(chrome.test.getConfig);
let port = config.testServer.port;
var URL_LOAD = "http://www.a.com:" + port +
"/extensions/api_test/webnavigation/serverRedirect/a.html";
var URL_LOAD_REDIRECT = "http://www.a.com:" + port + "/server-redirect";
chrome.test.runTests([
// Navigates to a page that redirects (on the server side) to a.html.
function serverRedirect() {
expect([
{ label: "a-onBeforeNavigate",
event: "onBeforeNavigate",
details: { documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: -1,
tabId: 0,
timeStamp: 0,
url: URL_LOAD_REDIRECT }},
{ label: "a-onCommitted",
event: "onCommitted",
details: { documentId: 1,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
transitionQualifiers: ["server_redirect"],
transitionType: "link",
url: URL_LOAD }},
{ label: "a-onDOMContentLoaded",
event: "onDOMContentLoaded",
details: { documentId: 1,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
url: URL_LOAD }},
{ label: "a-onCompleted",
event: "onCompleted",
details: { documentId: 1,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
url: URL_LOAD }}],
[ navigationOrder("a-") ]);
chrome.tabs.update(tab.id, { url: URL_LOAD_REDIRECT + "?" + URL_LOAD });
},
]);
});