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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/main.js

Issue 11368071: browser-plugin: Remove event handling code, and use CustomEvents in webkit instead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month 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
Index: chrome/test/data/extensions/platform_apps/web_view/main.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view/main.js b/chrome/test/data/extensions/platform_apps/web_view/main.js
index 9fcea5f2df96640d5c692d0c416ca2ad6c4a484f..9ff0c8ee959711ac04dae09a9f3295d0c03b6398 100644
--- a/chrome/test/data/extensions/platform_apps/web_view/main.js
+++ b/chrome/test/data/extensions/platform_apps/web_view/main.js
@@ -91,40 +91,6 @@ onload = function() {
}, 0);
},
- function webViewEventListeners() {
- var webview = document.createElement('webview');
- webview.setAttribute('src', 'data:text/html,webview check api');
- document.body.appendChild(webview);
-
- var validEvents = [
- 'exit',
- 'loadabort',
- 'loadredirect',
- 'loadstart',
- 'loadstop'
- ];
- var invalidEvents = [
- 'makemesandwich',
- 'sudomakemesandwich'
- ];
-
- // Timeout is necessary to give the mutation observers of the webview tag
- // shim a chance to fire.
- setTimeout(function() {
- for (var i = 0; i < validEvents.length; ++i) {
- chrome.test.assertTrue(
- webview.addEventListener(validEvents[i], function() {}));
- }
-
- for (var i = 0; i < invalidEvents.length; ++i) {
- chrome.test.assertFalse(
- webview.addEventListener(invalidEvents[i], function() {}));
- }
-
- chrome.test.succeed();
- }, 0);
- },
-
function webViewEventName() {
var webview = document.createElement('webview');
webview.setAttribute('src', 'data:text/html,webview check api');
@@ -132,16 +98,16 @@ onload = function() {
setTimeout(function() {
webview.addEventListener('loadstart', function(evt) {
- chrome.test.assertEq('loadstart', evt.name);
+ chrome.test.assertEq('loadstart', evt.type);
});
webview.addEventListener('loadstop', function(evt) {
- chrome.test.assertEq('loadstop', evt.name);
+ chrome.test.assertEq('loadstop', evt.type);
webview.terminate();
});
webview.addEventListener('exit', function(evt) {
- chrome.test.assertEq('exit', evt.name);
+ chrome.test.assertEq('exit', evt.type);
chrome.test.succeed();
});
@@ -174,14 +140,14 @@ onload = function() {
};
var onLoadCommitA = function(e) {
- chrome.test.assertEq('loadcommit', e.name);
- if (e.url == url) {
+ chrome.test.assertEq('loadcommit', e.type);
+ if (e.detail.url == url) {
updateLoadCommitCount();
}
};
var onLoadCommitB = function(e) {
- chrome.test.assertEq('loadcommit', e.name);
- if (e.url == url) {
+ chrome.test.assertEq('loadcommit', e.type);
+ if (e.detail.url == url) {
updateLoadCommitCount();
}
};
@@ -196,157 +162,6 @@ onload = function() {
}, 0);
},
- // This test checks the current behavior of dynamic event listener
- // registration 'during' an event listener fire.
- // Once an event starts firing its listeners, any mutation to the list of
- // event listeners for this event are deferred until all of the listeners
- // have fired.
- //
- // Step1: Loads a guest with |urlStep1| with two listeners to 'loadcommit':
- // onLoadCommitA and onLoadCommitB. When first of them fires, we try to
- // remove the other and add a third listener (onLoadCommitC).
- // Current expected behavior is these add/remove will be ignored and the
- // original two listeners will fire.
- // Step2: We change the guest to |urlStep2|. This will cause 'loadcommit' to
- // fire with mutated event listeners list (that is one of
- // onLoadCommitA/onLoadCommitB and onLoadCommitC).
- function dynamicEventListenerRegistrationOnListenerFire() {
- var urlStep1 = 'data:text/html,<body>Two</body>';
- var urlStep2 = 'data:text/html,<body>Three</body>';
- var webview = util.createWebViewTagInDOM();
-
- var listenerFireCount1 = 0; // Step 1 listeners.
- var listenerFireCount2 = 0; // Step 2 listeners.
-
- var loadCommitACalledStep1 = false;
- var loadCommitBCalledStep1 = false;
-
- var loadCommitACalledStep2 = false;
- var loadCommitBCalledStep2 = false;
- var loadCommitCCalledStep2 = false;
-
- var expectAToFireInStep2;
- var expectBToFireInStep2;
-
- var updateTestStateOnListenerStep1 = function() {
- ++listenerFireCount1;
- if (listenerFireCount1 == 1) { // First listener fire on Step 1.
- chrome.test.assertTrue(loadCommitACalledStep1 ||
- loadCommitBCalledStep1);
- // Add an event listener and remove one existing one when the first
- // listener fires. Current implmementation does not expect any of
- // these to be reflected before all event listeners are fired for the
- // current event.
-
- // Remove.
- if (loadCommitACalledStep1) {
- webview.removeEventListener('loadcommit', onLoadCommitB);
- expectAToFireInStep2 = true;
- expectBToFireInStep2 = false;
- } else {
- webview.removeEventListener('loadcommit', onLoadCommitA);
- expectAToFireInStep2 = false;
- expectBToFireInStep2 = true;
- }
- // Add the other one.
- webview.addEventListener('loadcommit', onLoadCommitC);
- } else if (listenerFireCount1 == 2) { // Last listener fire on Step 1.
- chrome.test.assertTrue(loadCommitACalledStep1 &&
- loadCommitBCalledStep1);
- // Move to Step 2.
- webview.setAttribute('src', urlStep2);
- } else {
- // More than expected listeners fired.
- chrome.test.fail();
- }
- };
-
- var updateTestStateOnListenerStep2 = function() {
- ++listenerFireCount2;
- if (listenerFireCount2 == 2) {
- // Exactly one of onLoadCommitA and onLoadCommitB must be called.
- chrome.test.assertTrue(loadCommitACalledStep2 ||
- loadCommitBCalledStep2);
- // onLoadCommitC must be called.
- chrome.test.assertTrue(loadCommitCCalledStep2);
-
- chrome.test.succeed();
- } else if (listenerFireCount2 > 2) {
- // More than expected listeners fired.
- chrome.test.fail();
- }
- };
-
- var onLoadCommitA = function(e) {
- chrome.test.assertEq('loadcommit', e.name);
- switch (e.url) {
- case urlStep1: // Step 1.
- chrome.test.log('Step 1. onLoadCommitA');
- chrome.test.assertFalse(loadCommitACalledStep1);
- loadCommitACalledStep1 = true;
-
- updateTestStateOnListenerStep1();
- break;
- case urlStep2: // Step 2.
- chrome.test.log('Step 2. onLoadCommitA');
- chrome.test.assertTrue(expectAToFireInStep2);
- // Can be called at most once.
- chrome.test.assertFalse(loadCommitACalledStep2);
- loadCommitACalledStep2 = true;
-
- updateTestStateOnListenerStep2();
- break;
- }
- };
-
- var onLoadCommitB = function(e) {
- chrome.test.assertEq('loadcommit', e.name);
- switch (e.url) {
- case urlStep1: // Step 1.
- chrome.test.log('Step 1. onLoadCommitB');
- chrome.test.assertFalse(loadCommitBCalledStep1);
- loadCommitBCalledStep1 = true;
-
- updateTestStateOnListenerStep1();
- break;
- case urlStep2: // Step 2.
- chrome.test.log('Step 2. onLoadCommitB');
- chrome.test.assertTrue(expecBToFireInStep2);
- // Can be called at most once.
- chrome.test.assertFalse(loadCommitBCalledStep2);
- loadCommitBCalledStep2 = true;
-
- updateTestStateOnListenerStep2();
- break;
- }
- };
-
- var onLoadCommitC = function(e) {
- chrome.test.assertEq('loadcommit', e.name);
- switch (e.url) {
- case urlStep1: // Step 1.
- chrome.test.fail();
- break;
- case urlStep2: // Step 2.
- chrome.test.log('Step 2. onLoadCommitC');
- chrome.test.assertFalse(loadCommitCCalledStep2);
- loadCommitCCalledStep2 = true;
-
- updateTestStateOnListenerStep2();
- break;
- }
- };
-
- setTimeout(function() {
- // The test starts from here, by setting the src to |urlStep1|. Event
- // listener registration works because we already have a (dummy) src set
- // on the <webview> tag.
- webview.addEventListener('loadcommit', onLoadCommitA);
- webview.addEventListener('loadcommit', onLoadCommitB);
- webview.setAttribute('src', urlStep1);
- }, 0);
- },
-
// This test registers two event listeners on a same event (loadcommit).
// Each of the listener tries to change some properties on the event param,
// which should not be possible.
@@ -359,33 +174,30 @@ onload = function() {
var maybeFinishTest = function(e) {
if (loadCommitACalled && loadCommitBCalled) {
- chrome.test.assertEq('loadcommit', e.name);
- chrome.test.assertTrue(e.isTopLevel);
+ chrome.test.assertEq('loadcommit', e.type);
chrome.test.succeed();
}
};
var onLoadCommitA = function(e) {
- if (e.url == url) {
- chrome.test.assertEq('loadcommit', e.name);
- chrome.test.assertTrue(e.isTopLevel);
+ if (e.detail.url == url) {
+ chrome.test.assertEq('loadcommit', e.type);
+ chrome.test.assertTrue(e.detail.isTopLevel);
chrome.test.assertFalse(loadCommitACalled);
loadCommitACalled = true;
// Try mucking with properities inside |e|.
- e.name = 'modified';
- e.isTopLevel = 'string-value';
+ e.type = 'modified';
maybeFinishTest(e);
}
};
var onLoadCommitB = function(e) {
- if (e.url == url) {
- chrome.test.assertEq('loadcommit', e.name);
- chrome.test.assertTrue(e.isTopLevel);
+ if (e.detail.url == url) {
+ chrome.test.assertEq('loadcommit', e.type);
+ chrome.test.assertTrue(e.detail.isTopLevel);
chrome.test.assertFalse(loadCommitBCalled);
loadCommitBCalled = true;
// Try mucking with properities inside |e|.
- e.name = 'modified';
- e.isTopLevel = 'string-value';
+ e.type = 'modified';
maybeFinishTest(e);
}
};
« no previous file with comments | « no previous file | content/renderer/browser_plugin/browser_plugin.h » ('j') | content/renderer/browser_plugin/browser_plugin.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698