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

Unified Diff: LayoutTests/fast/dom/HTMLElement/script-tests/contextmenu.js

Issue 243403006: Implement contextmenu attribute with basic support of <menu> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added test for RelatedEvent constructors Created 6 years, 4 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: LayoutTests/fast/dom/HTMLElement/script-tests/contextmenu.js
diff --git a/LayoutTests/fast/dom/HTMLElement/script-tests/contextmenu.js b/LayoutTests/fast/dom/HTMLElement/script-tests/contextmenu.js
new file mode 100644
index 0000000000000000000000000000000000000000..134bc1d028351fb17a63cdb1ea8c47830a5f68cc
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLElement/script-tests/contextmenu.js
@@ -0,0 +1,52 @@
+description('Tests the contextmenu attribute.');
tkent 2014/08/05 02:33:22 Please do not make new script-test. This file sho
+
+debug("Test with valid contextmenu attribute");
+document.write("<div id='container1' contextmenu='menu1'><menu id='menu1' type='popup' label='menu 1'></menu></div>");
+shouldBe("document.getElementById('container1').contextMenu.id", "'menu1'");
+shouldBe("document.getElementById('container1').contextMenu.type", "'popup'");
+shouldBe("document.getElementById('container1').contextMenu.label", "'menu 1'");
+
+debug("Test with invalid contextmenu attribute");
+document.write("<div id='container2' contextmenu='nonexistent_menu'><menu id='menu2' type='popup' label='menu 2'></menu></div>");
+shouldBe("document.getElementById('container2').contextMenu", "null");
+
tkent 2014/08/05 02:33:22 Need a test for a case where an element without co
+debug("Test setting contextmenu attribute");
+document.write("<div id='container3'></div>");
+var menu = document.createElement('menu');
+menu.id = 'menu3';
+menu.type = 'popup';
+menu.label = 'menu 3';
+document.getElementById('container3').appendChild(menu);
+var container3 = document.getElementById('container3');
+container3.contextMenu = menu;
+shouldBe("container3.contextMenu.id", "'menu3'");
tkent 2014/08/05 02:33:22 Use shouldBeEqualToString().
+shouldBe("container3.contextMenu.type", "'popup'");
+shouldBe("container3.contextMenu.label", "'menu 3'");
+
+debug("Test setting contextmenu attribute with menu element without id");
+document.write("<div id='container4'></div>");
+var menu1 = document.createElement('menu');
+menu1.type = 'popup';
+menu1.label = 'menu 4';
+document.getElementById('container4').appendChild(menu1);
+var container4 = document.getElementById('container4');
+container4.contextMenu = menu1;
+shouldBe("container4.contextMenu", "null");
tkent 2014/08/05 02:33:22 Use shouldBeNull().
+
+debug("Test setting contextmenu attribute with multiple menu element with same id");
+document.write("<div id='container5'></div>");
+var menu2 = document.createElement('menu');
+menu2.id = 'menu5';
+menu2.type = 'popup';
+menu2.label = 'menu 5';
+var menu3 = document.createElement('menu');
+menu3.id = 'menu5';
+menu3.type = 'popup';
+menu3.label = 'menu 6';
+document.getElementById('container5').appendChild(menu2);
+document.getElementById('container5').appendChild(menu3);
+var container5 = document.getElementById('container5');
+container5.contextMenu = menu2;
tkent 2014/08/05 02:33:22 Set menu3 instead of menu2. What should happen in
+shouldBe("container5.contextMenu.id", "'menu5'");
+shouldBe("container5.contextMenu.type", "'popup'");
+shouldBe("container5.contextMenu.label", "'menu 5'");
tkent 2014/08/05 02:33:22 What should happen if - element.contextMenu = nul

Powered by Google App Engine
This is Rietveld 408576698