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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/debugger/domdebugger-script-blocked-by-csp.js

Issue 2968523003: [DevTools] Migrate inspector-protocol/debugger tests to new harness (Closed)
Patch Set: all tests Created 3 years, 5 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
(Empty)
1 (async function(testRunner) {
2 let {page, session, dp} = await testRunner.startHTML(`
3 <html>
4 <head>
5 <meta http-equiv='Content-Security-Policy' content="script-src 'self';">
6 </head>
7 <body>
8 <button id='testButton' onclick='alert(1);'>Button</button>
9 </body>
10 </html>
11 `, ``);
12
13 dp.Debugger.enable();
14 dp.DOM.enable();
15 dp.DOMDebugger.enable();
16 dp.DOMDebugger.setInstrumentationBreakpoint({eventName: 'scriptBlockedByCSP'}) ;
17
18 var expressions = [
19 `
20 document.getElementById('testButton').click();
21 `,
22
23 `
24 var script = document.createElement('script');
25 script.innerText = 'alert(1)';
26 document.body.appendChild(script);
27 `,
28
29 `
30 var a = document.createElement('a');
31 a.setAttribute('href', 'javascript:alert(1);');
32 var dummy = 1;
33 document.body.appendChild(a); a.click();
34 `
35 ];
36 var descriptions = [
37 'blockedEventHandler',
38 'blockedScriptInjection',
39 'blockedScriptUrl'
40 ];
41
42 for (var i = 0; i < expressions.length; i++) {
43 var funcName = descriptions[i];
44 testRunner.log('\n-------\n' + funcName);
45 dp.Runtime.evaluate({expression: 'function ' + funcName + '() {' + expressio ns[i] + '}\n' + funcName + '()'});
46 var messageObject = await dp.Debugger.oncePaused();
47 var params = messageObject.params;
48 testRunner.log('Paused at: ' + params.callFrames[0].functionName + '@' + par ams.callFrames[0].location.lineNumber);
49 testRunner.log('Reason: ' + params.reason + '; Data:');
50 testRunner.logObject(params.data);
51 await dp.Debugger.resume();
52 }
53
54 testRunner.completeTest();
55 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698