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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/context_menus/basic/embedder.js

Issue 1026383003: <webview>: make context menus cancellable using JS API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments from yoz@ Created 5 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
Index: chrome/test/data/extensions/platform_apps/web_view/context_menus/basic/embedder.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view/context_menus/basic/embedder.js b/chrome/test/data/extensions/platform_apps/web_view/context_menus/basic/embedder.js
index 4963ff8053fa829adbc542949263715767726bac..65007eef249f2a2c4e40495a9f6ab17d0055f8ff 100644
--- a/chrome/test/data/extensions/platform_apps/web_view/context_menus/basic/embedder.js
+++ b/chrome/test/data/extensions/platform_apps/web_view/context_menus/basic/embedder.js
@@ -105,6 +105,26 @@ ContextMenuTester.prototype.testRemoveAllItems = function() {
});
};
+ContextMenuTester.prototype.registerPreventDefault = function() {
+ this.preventDefaultLister_ = function(e) {
+ e.preventDefault();
+ this.proceedTest_('DEFAULT_PREVENTED');
+ }.bind(this);
+
+ this.webview_.contextMenus.onShow.addListener(this.preventDefaultLister_);
+};
+
+ContextMenuTester.prototype.removePreventDefault = function() {
+ if (!this.preventDefaultLister_) {
+ LOG('Error: A listener is expected to setup prior to calling ' +
+ 'contextMenus.onShow');
+ return;
+ }
+ this.webview_.contextMenus.onShow.removeListener(this.preventDefaultLister_);
+
+ this.proceedTest_('PREVENT_DEFAULT_LISTENER_REMOVED');
+};
+
ContextMenuTester.prototype.onClick_ = function(type) {
if (type == 'global') {
this.globalClickCalled_ = true;
@@ -146,6 +166,12 @@ ContextMenuTester.prototype.proceedTest_ = function(step) {
case 'ITEM_ALL_REMOVED':
document.title = 'ITEM_ALL_REMOVED';
break;
+ case 'DEFAULT_PREVENTED':
+ chrome.test.sendMessage('WebViewTest.CONTEXT_MENU_DEFAULT_PREVENTED');
+ break;
+ case 'PREVENT_DEFAULT_LISTENER_REMOVED':
+ document.title = 'PREVENT_DEFAULT_LISTENER_REMOVED';
+ break;
default:
break;
}
@@ -187,9 +213,14 @@ window.createThreeMenuItems = function() {
tester.createThreeMenuItems();
};
window.removeAllItems = function() {
- LOG('window.testRemoveAllItems');
tester.testRemoveAllItems();
};
+window.registerPreventDefault = function() {
+ tester.registerPreventDefault();
+};
+window.removePreventDefault = function() {
+ tester.removePreventDefault();
+};
// window.* exported functions end.
function setUpTest(messageCallback) {

Powered by Google App Engine
This is Rietveld 408576698