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

Unified 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, 6 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: third_party/WebKit/LayoutTests/inspector-protocol/debugger/domdebugger-script-blocked-by-csp.js
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/debugger/domdebugger-script-blocked-by-csp.js b/third_party/WebKit/LayoutTests/inspector-protocol/debugger/domdebugger-script-blocked-by-csp.js
new file mode 100644
index 0000000000000000000000000000000000000000..8f700dbc59b8d7acc1fdcd0c8e3ce6a50838b139
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/debugger/domdebugger-script-blocked-by-csp.js
@@ -0,0 +1,55 @@
+(async function(testRunner) {
+ let {page, session, dp} = await testRunner.startHTML(`
+ <html>
+ <head>
+ <meta http-equiv='Content-Security-Policy' content="script-src 'self';">
+ </head>
+ <body>
+ <button id='testButton' onclick='alert(1);'>Button</button>
+ </body>
+ </html>
+ `, ``);
+
+ dp.Debugger.enable();
+ dp.DOM.enable();
+ dp.DOMDebugger.enable();
+ dp.DOMDebugger.setInstrumentationBreakpoint({eventName: 'scriptBlockedByCSP'});
+
+ var expressions = [
+ `
+ document.getElementById('testButton').click();
+ `,
+
+ `
+ var script = document.createElement('script');
+ script.innerText = 'alert(1)';
+ document.body.appendChild(script);
+ `,
+
+ `
+ var a = document.createElement('a');
+ a.setAttribute('href', 'javascript:alert(1);');
+ var dummy = 1;
+ document.body.appendChild(a); a.click();
+ `
+ ];
+ var descriptions = [
+ 'blockedEventHandler',
+ 'blockedScriptInjection',
+ 'blockedScriptUrl'
+ ];
+
+ for (var i = 0; i < expressions.length; i++) {
+ var funcName = descriptions[i];
+ testRunner.log('\n-------\n' + funcName);
+ dp.Runtime.evaluate({expression: 'function ' + funcName + '() {' + expressions[i] + '}\n' + funcName + '()'});
+ var messageObject = await dp.Debugger.oncePaused();
+ var params = messageObject.params;
+ testRunner.log('Paused at: ' + params.callFrames[0].functionName + '@' + params.callFrames[0].location.lineNumber);
+ testRunner.log('Reason: ' + params.reason + '; Data:');
+ testRunner.logObject(params.data);
+ await dp.Debugger.resume();
+ }
+
+ testRunner.completeTest();
+})

Powered by Google App Engine
This is Rietveld 408576698