Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 onload = function() { | 5 onload = function() { |
| 6 var getURL = chrome.extension.getURL; | 6 var getURL = chrome.extension.getURL; |
| 7 var URL_MAIN = getURL("a.html"); | |
| 8 var SUBFRAME_URL = | |
| 9 "http://127.0.0.1:PORT/extensions/api_test/webnavigation/userAction/su bframe.html"; | |
| 10 | |
| 7 chrome.tabs.create({"url": "about:blank"}, function(tab) { | 11 chrome.tabs.create({"url": "about:blank"}, function(tab) { |
| 8 var tabId = tab.id; | 12 var tabId = tab.id; |
| 9 | 13 |
| 10 chrome.test.runTests([ | 14 chrome.test.getConfig(function(config) { |
| 11 // Opens a tab and waits for the user to click on a link in it. | 15 var fixPort = function(url) { |
| 12 function userAction() { | 16 return url.replace(/PORT/g, config.testServer.port); |
| 13 expect([ | 17 }; |
| 14 { label: "a-onBeforeNavigate", | 18 SUBFRAME_URL = fixPort(SUBFRAME_URL); |
| 15 event: "onBeforeNavigate", | |
| 16 details: { frameId: 0, | |
| 17 parentFrameId: -1, | |
| 18 processId: -1, | |
| 19 tabId: 0, | |
| 20 timeStamp: 0, | |
| 21 url: getURL('a.html') }}, | |
| 22 { label: "a-onCommitted", | |
| 23 event: "onCommitted", | |
| 24 details: { frameId: 0, | |
| 25 processId: 0, | |
| 26 tabId: 0, | |
| 27 timeStamp: 0, | |
| 28 transitionQualifiers: [], | |
| 29 transitionType: "typed", | |
| 30 url: getURL('a.html') }}, | |
| 31 { label: "a-onDOMContentLoaded", | |
| 32 event: "onDOMContentLoaded", | |
| 33 details: { frameId: 0, | |
| 34 processId: 0, | |
| 35 tabId: 0, | |
| 36 timeStamp: 0, | |
| 37 url: getURL('a.html') }}, | |
| 38 { label: "a-onCompleted", | |
| 39 event: "onCompleted", | |
| 40 details: { frameId: 0, | |
| 41 processId: 0, | |
| 42 tabId: 0, | |
| 43 timeStamp: 0, | |
| 44 url: getURL('a.html') }}, | |
| 45 { label: "b-onCreatedNavigationTarget", | |
| 46 event: "onCreatedNavigationTarget", | |
| 47 details: { sourceFrameId: 0, | |
| 48 sourceProcessId: 0, | |
| 49 sourceTabId: 0, | |
| 50 tabId: 1, | |
| 51 timeStamp: 0, | |
| 52 url: getURL('b.html') }}, | |
| 53 { label: "b-onBeforeNavigate", | |
| 54 event: "onBeforeNavigate", | |
| 55 details: { frameId: 0, | |
| 56 parentFrameId: -1, | |
| 57 processId: -1, | |
| 58 tabId: 1, | |
| 59 timeStamp: 0, | |
| 60 url: getURL('b.html') }}, | |
| 61 { label: "b-onCommitted", | |
| 62 event: "onCommitted", | |
| 63 details: { frameId: 0, | |
| 64 processId: 0, | |
| 65 tabId: 1, | |
| 66 timeStamp: 0, | |
| 67 transitionQualifiers: [], | |
| 68 transitionType: "link", | |
| 69 url: getURL('b.html') }}, | |
| 70 { label: "b-onDOMContentLoaded", | |
| 71 event: "onDOMContentLoaded", | |
| 72 details: { frameId: 0, | |
| 73 processId: 0, | |
| 74 tabId: 1, | |
| 75 timeStamp: 0, | |
| 76 url: getURL('b.html') }}, | |
| 77 { label: "b-onCompleted", | |
| 78 event: "onCompleted", | |
| 79 details: { frameId: 0, | |
| 80 processId: 0, | |
| 81 tabId: 1, | |
| 82 timeStamp: 0, | |
| 83 url: getURL('b.html') }}], | |
| 84 [ navigationOrder("a-"), | |
| 85 navigationOrder("b-"), | |
| 86 [ "a-onDOMContentLoaded", | |
| 87 "b-onCreatedNavigationTarget", | |
| 88 "b-onBeforeNavigate" ]]); | |
| 89 | 19 |
| 90 // Notify the api test that we're waiting for the user. | 20 chrome.test.runTests([ |
| 91 chrome.test.notifyPass(); | 21 // Opens a tab and waits for the user to click on a link in it. |
| 92 }, | 22 function userAction() { |
| 93 ]); | 23 expect([ |
| 24 { label: "a-onBeforeNavigate", | |
|
Charlie Reis
2016/10/03 22:15:23
You'll need another reviewer for this part-- I can
Charlie Reis
2016/10/03 22:32:51
Thanks for explaining offline. (It'd be nice to e
| |
| 25 event: "onBeforeNavigate", | |
| 26 details: { frameId: 0, | |
| 27 parentFrameId: -1, | |
| 28 processId: -1, | |
| 29 tabId: 0, | |
| 30 timeStamp: 0, | |
| 31 url: URL_MAIN }}, | |
| 32 { label: "a-onCommitted", | |
| 33 event: "onCommitted", | |
| 34 details: { frameId: 0, | |
| 35 processId: 0, | |
| 36 tabId: 0, | |
| 37 timeStamp: 0, | |
| 38 transitionQualifiers: [], | |
| 39 transitionType: "typed", | |
| 40 url: URL_MAIN }}, | |
| 41 { label: "a-onDOMContentLoaded", | |
| 42 event: "onDOMContentLoaded", | |
| 43 details: { frameId: 0, | |
| 44 processId: 0, | |
| 45 tabId: 0, | |
| 46 timeStamp: 0, | |
| 47 url: URL_MAIN }}, | |
| 48 { label: "a-onCompleted", | |
| 49 event: "onCompleted", | |
| 50 details: { frameId: 0, | |
| 51 processId: 0, | |
| 52 tabId: 0, | |
| 53 timeStamp: 0, | |
| 54 url: URL_MAIN }}, | |
| 55 | |
| 56 { label: "subframe-onBeforeNavigate", | |
| 57 event: "onBeforeNavigate", | |
| 58 details: { frameId: 1, | |
| 59 parentFrameId: 0, | |
| 60 processId: -1, | |
| 61 tabId: 0, | |
| 62 timeStamp: 0, | |
| 63 url: SUBFRAME_URL }}, | |
| 64 { label: "subframe-onCommitted", | |
| 65 event: "onCommitted", | |
| 66 details: { frameId: 1, | |
| 67 processId: 1, | |
| 68 tabId: 0, | |
| 69 timeStamp: 0, | |
| 70 transitionQualifiers: [], | |
| 71 transitionType: "auto_subframe", | |
| 72 url: SUBFRAME_URL }}, | |
| 73 { label: "subframe-onDOMContentLoaded", | |
| 74 event: "onDOMContentLoaded", | |
| 75 details: { frameId: 1, | |
| 76 processId: 1, | |
| 77 tabId: 0, | |
| 78 timeStamp: 0, | |
| 79 url: SUBFRAME_URL }}, | |
| 80 { label: "subframe-onCompleted", | |
| 81 event: "onCompleted", | |
| 82 details: { frameId: 1, | |
| 83 processId: 1, | |
| 84 tabId: 0, | |
| 85 timeStamp: 0, | |
| 86 url: SUBFRAME_URL }}, | |
| 87 | |
| 88 { label: "b-onCreatedNavigationTarget", | |
| 89 event: "onCreatedNavigationTarget", | |
| 90 details: { sourceFrameId: 1, | |
| 91 sourceProcessId: 0, | |
| 92 sourceTabId: 0, | |
| 93 tabId: 1, | |
| 94 timeStamp: 0, | |
| 95 url: getURL('b.html') }}, | |
| 96 { label: "b-onBeforeNavigate", | |
| 97 event: "onBeforeNavigate", | |
| 98 details: { frameId: 0, | |
| 99 parentFrameId: -1, | |
| 100 processId: -1, | |
| 101 tabId: 1, | |
| 102 timeStamp: 0, | |
| 103 url: getURL('b.html') }}, | |
| 104 { label: "b-onCommitted", | |
| 105 event: "onCommitted", | |
| 106 details: { frameId: 0, | |
| 107 processId: 0, | |
| 108 tabId: 1, | |
| 109 timeStamp: 0, | |
| 110 transitionQualifiers: [], | |
| 111 transitionType: "link", | |
| 112 url: getURL('b.html') }}, | |
| 113 { label: "b-onDOMContentLoaded", | |
| 114 event: "onDOMContentLoaded", | |
| 115 details: { frameId: 0, | |
| 116 processId: 0, | |
| 117 tabId: 1, | |
| 118 timeStamp: 0, | |
| 119 url: getURL('b.html') }}, | |
| 120 { label: "b-onCompleted", | |
| 121 event: "onCompleted", | |
| 122 details: { frameId: 0, | |
| 123 processId: 0, | |
| 124 tabId: 1, | |
| 125 timeStamp: 0, | |
| 126 url: getURL('b.html') }}], | |
| 127 [ navigationOrder("a-"), | |
| 128 navigationOrder("subframe-"), | |
| 129 navigationOrder("b-"), | |
| 130 [ "a-onCompleted", | |
| 131 "b-onCreatedNavigationTarget", | |
| 132 "b-onBeforeNavigate" ]]); | |
| 133 | |
| 134 // Notify the api test that we're waiting for the user. | |
| 135 chrome.test.notifyPass(); | |
| 136 }, | |
| 137 ]); | |
| 138 }); | |
| 94 }); | 139 }); |
| 95 }; | 140 }; |
| OLD | NEW |