Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / webnavigation / crossProcessFragment / test_crossProcessFragment.js
blob8097753af2ac58869ebcb95fb44e6af1888f06c6
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 onload = function() {
6   var getURL = chrome.extension.getURL;
7   var URL_TEST = "http://127.0.0.1:PORT/test";
8   chrome.tabs.create({"url": "about:blank"}, function(tab) {
9     var tabId = tab.id;
10     chrome.test.getConfig(function(config) {
11       var fixPort = function(url) {
12         return url.replace(/PORT/g, config.testServer.port);
13       };
14       URL_TEST = fixPort(URL_TEST);
16       chrome.test.runTests([
17         // Navigates to a different site, but then modifies the reference
18         // framgent.
19         function crossProcessFragment() {
20           expect([
21             { label: "a-onBeforeNavigate",
22               event: "onBeforeNavigate",
23               details: { frameId: 0,
24                          parentFrameId: -1,
25                          processId: 0,
26                          tabId: 0,
27                          timeStamp: 0,
28                          url: getURL('f.html') }},
29             { label: "a-onCommitted",
30               event: "onCommitted",
31               details: { frameId: 0,
32                          processId: 0,
33                          tabId: 0,
34                          timeStamp: 0,
35                          transitionQualifiers: [],
36                          transitionType: "link",
37                          url: getURL('f.html') }},
38             { label: "a-onDOMContentLoaded",
39               event: "onDOMContentLoaded",
40               details: { frameId: 0,
41                          processId: 0,
42                          tabId: 0,
43                          timeStamp: 0,
44                          url: getURL('f.html') }},
45             { label: "a-onCompleted",
46               event: "onCompleted",
47               details: { frameId: 0,
48                          processId: 0,
49                          tabId: 0,
50                          timeStamp: 0,
51                          url: getURL('f.html') }},
52             { label: "a-onReferenceFragmentUpdated",
53               event: "onReferenceFragmentUpdated",
54               details: { frameId: 0,
55                          processId: 0,
56                          tabId: 0,
57                          timeStamp: 0,
58                          transitionQualifiers: [],
59                          transitionType: "link",
60                          url: getURL('f.html#foo') }},
61             { label: "b-onBeforeNavigate",
62               event: "onBeforeNavigate",
63               details: { frameId: 0,
64                          parentFrameId: -1,
65                          processId: 1,
66                          tabId: 0,
67                          timeStamp: 0,
68                          url: URL_TEST + "3" }},
69             { label: "b-onCommitted",
70               event: "onCommitted",
71               details: { frameId: 0,
72                          processId: 1,
73                          tabId: 0,
74                          timeStamp: 0,
75                          transitionQualifiers: [],
76                          transitionType: "link",
77                          url: URL_TEST + "3" }},
78             { label: "b-onDOMContentLoaded",
79               event: "onDOMContentLoaded",
80               details: { frameId: 0,
81                          processId: 1,
82                          tabId: 0,
83                          timeStamp: 0,
84                          url: URL_TEST + "3" }},
85             { label: "b-onCompleted",
86               event: "onCompleted",
87               details: { frameId: 0,
88                          processId: 1,
89                          tabId: 0,
90                          timeStamp: 0,
91                          url: URL_TEST + "3" }}],
92             [ navigationOrder("a-"),
93               [ "a-onCompleted", "b-onBeforeNavigate",
94                 "a-onReferenceFragmentUpdated", "b-onCommitted"] ]);
96           chrome.tabs.update(
97               tabId,
98               { url: getURL('f.html?' +
99                             config.testServer.port) });
100         },
102         // A page with an iframe that changes its reference fragment before
103         // the iframe committed.
104         function crossProcessFragmentIFrame() {
105           expect([
106             { label: "a-onBeforeNavigate",
107               event: "onBeforeNavigate",
108               details: { frameId: 0,
109                          parentFrameId: -1,
110                          processId: 0,
111                          tabId: 0,
112                          timeStamp: 0,
113                          url: getURL('g.html') }},
114             { label: "a-onCommitted",
115               event: "onCommitted",
116               details: { frameId: 0,
117                          processId: 0,
118                          tabId: 0,
119                          timeStamp: 0,
120                          transitionQualifiers: [],
121                          transitionType: "link",
122                          url: getURL('g.html') }},
123             { label: "a-onDOMContentLoaded",
124               event: "onDOMContentLoaded",
125               details: { frameId: 0,
126                          processId: 0,
127                          tabId: 0,
128                          timeStamp: 0,
129                          url: getURL('g.html') }},
130             { label: "a-onCompleted",
131               event: "onCompleted",
132               details: { frameId: 0,
133                          processId: 0,
134                          tabId: 0,
135                          timeStamp: 0,
136                          url: getURL('g.html') }},
137             { label: "a-onReferenceFragmentUpdated",
138               event: "onReferenceFragmentUpdated",
139               details: { frameId: 0,
140                          processId: 0,
141                          tabId: 0,
142                          timeStamp: 0,
143                          transitionQualifiers: [],
144                          transitionType: "link",
145                          url: getURL('g.html#foo') }},
146             { label: "b-onBeforeNavigate",
147               event: "onBeforeNavigate",
148               details: { frameId: 1,
149                          parentFrameId: 0,
150                          processId: 0,
151                          tabId: 0,
152                          timeStamp: 0,
153                          url: URL_TEST + "4" }},
154             { label: "b-onCommitted",
155               event: "onCommitted",
156               details: { frameId: 1,
157                          processId: 0,
158                          tabId: 0,
159                          timeStamp: 0,
160                          transitionQualifiers: [],
161                          transitionType: "auto_subframe",
162                          url: URL_TEST + "4" }},
163             { label: "b-onDOMContentLoaded",
164               event: "onDOMContentLoaded",
165               details: { frameId: 1,
166                          processId: 0,
167                          tabId: 0,
168                          timeStamp: 0,
169                          url: URL_TEST + "4" }},
170             { label: "b-onCompleted",
171               event: "onCompleted",
172               details: { frameId: 1,
173                          processId: 0,
174                          tabId: 0,
175                          timeStamp: 0,
176                          url: URL_TEST + "4" }}],
177             [ navigationOrder("a-"), navigationOrder("b-"),
178               [ "a-onCompleted", "b-onBeforeNavigate",
179                 "a-onReferenceFragmentUpdated"] ]);
181           chrome.tabs.update(
182               tabId,
183               { url: getURL('g.html?' +
184                             config.testServer.port) });
185         },
187       ]);
188     });
189   });