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

Unified Diff: chrome/test/data/extensions/api_test/native_bindings/extension/background.js

Issue 2768093002: [Reland][Extensions Bindings] Add support for filtered events (Closed)
Patch Set: Fix Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/native_bindings/extension/manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/native_bindings/extension/background.js
diff --git a/chrome/test/data/extensions/api_test/native_bindings/extension/background.js b/chrome/test/data/extensions/api_test/native_bindings/extension/background.js
index 43128091ca427ce4ce72a0f54907a5dfd848aa4d..2c2d19ee2f6c688bb50ab2486149bad237b00972 100644
--- a/chrome/test/data/extensions/api_test/native_bindings/extension/background.js
+++ b/chrome/test/data/extensions/api_test/native_bindings/extension/background.js
@@ -206,6 +206,54 @@ var tests = [
chrome.test.succeed();
});
},
+ function testWebNavigationAndFilteredEvents() {
+ // Tests unfiltered events, which can be exercised with the webNavigation
+ // API.
+ var unfiltered = new Promise((resolve, reject) => {
+ var sawSimple1 = false;
+ var sawSimple2 = false;
+ chrome.webNavigation.onBeforeNavigate.addListener(
+ function listener(details) {
+ // We create a bunch of tabs in other tests, which can potentially
+ // show up here. If this becomes too much of a problem, we can isolate
+ // these tests further, but for now, just using a unique url should be
+ // sufficient.
+ if (details.url.indexOf('unique') == -1)
+ return;
+ if (details.url.indexOf('simple.html') != -1)
+ sawSimple1 = true;
+ else if (details.url.indexOf('simple2.html') != -1)
+ sawSimple2 = true;
+ else
+ chrome.test.fail(details.url);
+
+ if (sawSimple1 && sawSimple2) {
+ chrome.webNavigation.onBeforeNavigate.removeListener(listener);
+ resolve();
+ }
+ });
+ });
+
+ var filtered = new Promise((resolve, reject) => {
+ chrome.webNavigation.onBeforeNavigate.addListener(
+ function listener(details) {
+ chrome.test.assertTrue(details.url.indexOf('unique') != -1);
+ chrome.test.assertTrue(details.url.indexOf('simple2.html') != -1,
+ details.url);
+ chrome.webNavigation.onBeforeNavigate.removeListener(listener);
+ resolve();
+ }, {url: [{pathContains: 'simple2.html'}]});
+ });
+
+ var url1 =
+ 'http://unique.com:' + portNumber + '/native_bindings/simple.html';
+ var url2 =
+ 'http://unique.com:' + portNumber + '/native_bindings/simple2.html';
+ chrome.tabs.create({url: url1});
+ chrome.tabs.create({url: url2});
+
+ Promise.all([unfiltered, filtered]).then(() => { chrome.test.succeed(); });
+ },
];
chrome.test.getConfig(config => {
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/native_bindings/extension/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698