// 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() {
var getURL = chrome.runtime.getURL;
let tab = await promise(chrome.tabs.create, {"url": "about:blank"});
chrome.test.runTests([
// Reference fragment navigation.
function referenceFragment() {
expect([
{ label: "a-onBeforeNavigate",
event: "onBeforeNavigate",
details: { documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: -1,
tabId: 0,
timeStamp: 0,
url: getURL('a.html') }},
{ label: "a-onCommitted",
event: "onCommitted",
details: { documentId: 1,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
transitionQualifiers: [],
transitionType: "link",
url: getURL('a.html') }},
{ label: "a-onDOMContentLoaded",
event: "onDOMContentLoaded",
details: { documentId: 1,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
url: getURL('a.html') }},
{ label: "a-onCompleted",
event: "onCompleted",
details: { documentId: 1,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
url: getURL('a.html#anchor') }},
{ label: "a-onReferenceFragmentUpdated",
event: "onReferenceFragmentUpdated",
details: { documentId: 1,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
transitionQualifiers: ["client_redirect"],
transitionType: "link",
url: getURL('a.html#anchor') }}
],
[ navigationOrder("a-") ]);
chrome.tabs.update(tab.id, { url: getURL('a.html') });
},
// This is a test case in which a fragment navigation as a result of a
// click is followed by a load of the original URL. The load of the
// original URL has the potential to be confused for a fragment
// navigation, since they differ only in the fragment.
// See https://crbug.com/732083.
function locationAssignAfterFragment() {
expect([
{ label: "b-onBeforeNavigate",
event: "onBeforeNavigate",
details: { documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: -1,
tabId: 0,
timeStamp: 0,
url: getURL('b.html') }},
{ label: "b-onCommitted",
event: "onCommitted",
details: { documentId: 1,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
transitionQualifiers: [],
transitionType: "link",
url: getURL('b.html') }},
{ label: "b-onDOMContentLoaded",
event: "onDOMContentLoaded",
details: { documentId: 1,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
url: getURL('b.html') }},
{ label: "b-onCompleted",
event: "onCompleted",
details: { documentId: 1,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
url: getURL('b.html') }},
{ label: "b-onReferenceFragmentUpdated",
event: "onReferenceFragmentUpdated",
details: { documentId: 1,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
transitionQualifiers: [],
transitionType: "link",
url: getURL('b.html#') }},
{ label: "b1-onBeforeNavigate",
event: "onBeforeNavigate",
details: { documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: -1,
tabId: 0,
timeStamp: 0,
url: getURL('b.html') }},
{ label: "b1-onCommitted",
event: "onCommitted",
details: { documentId: 2,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
transitionQualifiers: ["client_redirect"],
transitionType: "link",
url: getURL('b.html') }},
{ label: "b1-onDOMContentLoaded",
event: "onDOMContentLoaded",
details: { documentId: 2,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
url: getURL('b.html') }},
{ label: "b1-onCompleted",
event: "onCompleted",
details: { documentId: 2,
documentLifecycle: "active",
frameId: 0,
frameType: "outermost_frame",
parentFrameId: -1,
processId: 0,
tabId: 0,
timeStamp: 0,
url: getURL('b.html') }},
],
[ navigationOrder("b-"), navigationOrder("b1-") ]);
chrome.tabs.update(tab.id, { url: getURL('b.html') });
},
]);
});