- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / webnavigation / test_crossProcessFragment.js
1 // Copyright (c) 2012 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.
4
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);
15
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('crossProcess/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('crossProcess/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('crossProcess/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('crossProcess/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('crossProcess/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-onErrorOccurred",
70               event: "onErrorOccurred",
71               details: { error: "net::ERR_ABORTED",
72                          frameId: 0,
73                          processId: 1,
74                          tabId: 0,
75                          timeStamp: 0,
76                          url: URL_TEST + "3" }}],
77             [ navigationOrder("a-"),
78               [ "a-onCompleted", "b-onBeforeNavigate",
79                 "a-onReferenceFragmentUpdated"] ]);
80
81           chrome.tabs.update(
82               tabId,
83               { url: getURL('crossProcess/f.html?' + config.testServer.port) });
84         },
85
86         // A page with an iframe that changes its reference fragment before
87         // the iframe committed.
88         function crossProcessFragmentIFrame() {
89           expect([
90             { label: "a-onBeforeNavigate",
91               event: "onBeforeNavigate",
92               details: { frameId: 0,
93                          parentFrameId: -1,
94                          processId: 0,
95                          tabId: 0,
96                          timeStamp: 0,
97                          url: getURL('crossProcess/g.html') }},
98             { label: "a-onCommitted",
99               event: "onCommitted",
100               details: { frameId: 0,
101                          processId: 0,
102                          tabId: 0,
103                          timeStamp: 0,
104                          transitionQualifiers: [],
105                          transitionType: "link",
106                          url: getURL('crossProcess/g.html') }},
107             { label: "a-onDOMContentLoaded",
108               event: "onDOMContentLoaded",
109               details: { frameId: 0,
110                          processId: 0,
111                          tabId: 0,
112                          timeStamp: 0,
113                          url: getURL('crossProcess/g.html') }},
114             { label: "a-onCompleted",
115               event: "onCompleted",
116               details: { frameId: 0,
117                          processId: 0,
118                          tabId: 0,
119                          timeStamp: 0,
120                          url: getURL('crossProcess/g.html') }},
121             { label: "a-onReferenceFragmentUpdated",
122               event: "onReferenceFragmentUpdated",
123               details: { frameId: 0,
124                          processId: 0,
125                          tabId: 0,
126                          timeStamp: 0,
127                          transitionQualifiers: [],
128                          transitionType: "link",
129                          url: getURL('crossProcess/g.html#foo') }},
130             { label: "b-onBeforeNavigate",
131               event: "onBeforeNavigate",
132               details: { frameId: 1,
133                          parentFrameId: 0,
134                          processId: 0,
135                          tabId: 0,
136                          timeStamp: 0,
137                          url: URL_TEST + "4" }},
138             { label: "b-onCommitted",
139               event: "onCommitted",
140               details: { frameId: 1,
141                          processId: 0,
142                          tabId: 0,
143                          timeStamp: 0,
144                          transitionQualifiers: [],
145                          transitionType: "auto_subframe",
146                          url: URL_TEST + "4" }},
147             { label: "b-onDOMContentLoaded",
148               event: "onDOMContentLoaded",
149               details: { frameId: 1,
150                          processId: 0,
151                          tabId: 0,
152                          timeStamp: 0,
153                          url: URL_TEST + "4" }},
154             { label: "b-onCompleted",
155               event: "onCompleted",
156               details: { frameId: 1,
157                          processId: 0,
158                          tabId: 0,
159                          timeStamp: 0,
160                          url: URL_TEST + "4" }}],
161             [ navigationOrder("a-"), navigationOrder("b-"),
162               [ "a-onCompleted", "b-onBeforeNavigate",
163                 "a-onReferenceFragmentUpdated"] ]);
164
165           chrome.tabs.update(
166               tabId,
167               { url: getURL('crossProcess/g.html?' + config.testServer.port) });
168         },
169
170       ]);
171     });
172   });
173 };