Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/test/data/extensions/api_test/webnavigation/framework.js

Issue 10815051: Send the correct process ID with webNavigation events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var deepEq = chrome.test.checkDeepEq; 5 var deepEq = chrome.test.checkDeepEq;
6 var expectedEventData; 6 var expectedEventData;
7 var expectedEventOrder; 7 var expectedEventOrder;
8 var capturedEventData; 8 var capturedEventData;
9 var nextFrameId; 9 var nextFrameId;
10 var frameIds; 10 var frameIds;
11 var nextTabId; 11 var nextTabId;
12 var tabIds; 12 var tabIds;
13 var nextProcessId;
14 var processIds;
13 var initialized = false; 15 var initialized = false;
14 16
15 function deepCopy(obj) { 17 function deepCopy(obj) {
16 if (obj === null) 18 if (obj === null)
17 return null; 19 return null;
18 if (typeof(obj) != 'object') 20 if (typeof(obj) != 'object')
19 return obj; 21 return obj;
20 if (Array.isArray(obj)) { 22 if (Array.isArray(obj)) {
21 var tmp_array = new Array; 23 var tmp_array = new Array;
22 for (var i = 0; i < obj.length; i++) { 24 for (var i = 0; i < obj.length; i++) {
(...skipping 18 matching lines...) Expand all
41 // event with label "a" needs to occur before event with label "b". The 43 // event with label "a" needs to occur before event with label "b". The
42 // relative order of "a" and "d" does not matter. 44 // relative order of "a" and "d" does not matter.
43 function expect(data, order) { 45 function expect(data, order) {
44 expectedEventData = data; 46 expectedEventData = data;
45 capturedEventData = []; 47 capturedEventData = [];
46 expectedEventOrder = order; 48 expectedEventOrder = order;
47 nextFrameId = 1; 49 nextFrameId = 1;
48 frameIds = {}; 50 frameIds = {};
49 nextTabId = 0; 51 nextTabId = 0;
50 tabIds = {}; 52 tabIds = {};
53 nextProcessId = 0;
54 processIds = {}
51 initListeners(); 55 initListeners();
52 } 56 }
53 57
54 function checkExpectations() { 58 function checkExpectations() {
55 if (capturedEventData.length < expectedEventData.length) { 59 if (capturedEventData.length < expectedEventData.length) {
56 return; 60 return;
57 } 61 }
58 if (capturedEventData.length > expectedEventData.length) { 62 if (capturedEventData.length > expectedEventData.length) {
59 chrome.test.fail("Recorded too many events. " + 63 chrome.test.fail("Recorded too many events. " +
60 JSON.stringify(capturedEventData)); 64 JSON.stringify(capturedEventData));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 tabIds[details.sourceTabId] = nextTabId++; 127 tabIds[details.sourceTabId] = nextTabId++;
124 } 128 }
125 details.sourceTabId = tabIds[details.sourceTabId]; 129 details.sourceTabId = tabIds[details.sourceTabId];
126 } 130 }
127 if ('replacedTabId' in details) { 131 if ('replacedTabId' in details) {
128 if (tabIds[details.replacedTabId] === undefined) { 132 if (tabIds[details.replacedTabId] === undefined) {
129 tabIds[details.replacedTabId] = nextTabId++; 133 tabIds[details.replacedTabId] = nextTabId++;
130 } 134 }
131 details.replacedTabId = tabIds[details.replacedTabId]; 135 details.replacedTabId = tabIds[details.replacedTabId];
132 } 136 }
133 // Don't bother testing those before we don't correctly dispatch events for
134 // cross process navigations.
135 if ('processId' in details) { 137 if ('processId' in details) {
136 delete details.processId; 138 if (processIds[details.processId] === undefined) {
139 processIds[details.processId] = nextProcessId++;
140 }
141 details.processId = processIds[details.processId];
137 } 142 }
138 if ('sourceProcessId' in details) { 143 if ('sourceProcessId' in details) {
139 delete details.sourceProcessId; 144 if (processIds[details.sourceProcessId] === undefined) {
145 processIds[details.sourceProcessId] = nextProcessId++;
146 }
147 details.sourceProcessId = processIds[details.sourceProcessId];
140 } 148 }
141 149
142 // find |details| in expectedEventData 150 // find |details| in expectedEventData
143 var found = false; 151 var found = false;
144 var label = undefined; 152 var label = undefined;
145 expectedEventData.forEach(function (exp) { 153 expectedEventData.forEach(function (exp) {
146 if (exp.event == name) { 154 if (exp.event == name) {
147 var exp_details; 155 var exp_details;
148 var alt_details; 156 var alt_details;
149 if ('transitionQualifiers' in exp.details) { 157 if ('transitionQualifiers' in exp.details) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 iframe + "onBeforeNavigate", 244 iframe + "onBeforeNavigate",
237 main_frame + "onDOMContentLoaded", 245 main_frame + "onDOMContentLoaded",
238 iframe + "onCompleted", 246 iframe + "onCompleted",
239 main_frame + "onCompleted" ]; 247 main_frame + "onCompleted" ];
240 } 248 }
241 249
242 // Returns the constraint expressing that a frame was loaded by another. 250 // Returns the constraint expressing that a frame was loaded by another.
243 function isLoadedBy(target, source) { 251 function isLoadedBy(target, source) {
244 return [ source + "onDOMContentLoaded", target + "onBeforeNavigate"]; 252 return [ source + "onDOMContentLoaded", target + "onBeforeNavigate"];
245 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698