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

Side by Side Diff: chrome/test/data/webui/util_test.html

Issue 2184123003: Use event path to detect if anchor has been clicked in WebUIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@close_dialog_on_query
Patch Set: add test to util_test.html Created 4 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <a id="file" href="file:///path/to/file">File</a>
5 <a id="chrome" href="about:chrome">Chrome</a>
4 <script> 6 <script>
5 7
6 function testQuoteString() { 8 function testQuoteString() {
7 // Basic cases. 9 // Basic cases.
8 assertEquals('\"test\"', quoteString('"test"')); 10 assertEquals('\"test\"', quoteString('"test"'));
9 assertEquals('\\!\\?', quoteString('!?')); 11 assertEquals('\\!\\?', quoteString('!?'));
10 assertEquals('\\(\\._\\.\\) \\( \\:l \\) \\(\\.-\\.\\)', 12 assertEquals('\\(\\._\\.\\) \\( \\:l \\) \\(\\.-\\.\\)',
11 quoteString('(._.) ( :l ) (.-.)')); 13 quoteString('(._.) ( :l ) (.-.)'));
12 14
13 // Using the output as a regex. 15 // Using the output as a regex.
14 var re = new RegExp(quoteString('"hello"'), 'gim'); 16 var re = new RegExp(quoteString('"hello"'), 'gim');
15 var match = re.exec('She said "Hello" loudly'); 17 var match = re.exec('She said "Hello" loudly');
16 assertEquals(9, match.index); 18 assertEquals(9, match.index);
17 19
18 re = new RegExp(quoteString('Hello, .*'), 'gim'); 20 re = new RegExp(quoteString('Hello, .*'), 'gim');
19 match = re.exec('Hello, world'); 21 match = re.exec('Hello, world');
20 assertEquals(null, match); 22 assertEquals(null, match);
21 } 23 }
22 24
25 function testClickHandler() {
26 var lastArgs = null;
27 chrome.send = function(message, args) {
Dan Beam 2016/08/02 06:02:43 also a bummer
Dan Beam 2016/08/02 06:02:43 at least replace this, IMO, after you're done
calamity 2016/08/08 05:06:43 Done.
28 assertEquals('navigateToUrl', message);
29 lastArgs = args;
Dan Beam 2016/08/02 06:02:43 clickArgs or clickParams, IMO
calamity 2016/08/08 05:06:43 Done.
30 }
Dan Beam 2016/08/02 06:02:43 };
calamity 2016/08/08 05:06:43 Done.
31 $('file').click();
32 assertEquals('file:///path/to/file', lastArgs[0]);
33 $('chrome').click();
34 assertEquals('about:chrome', lastArgs[0]);
35 }
36
23 </script> 37 </script>
24 </body> 38 </body>
25 </html> 39 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698