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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/xssAuditor/resources/utilities.js

Issue 2425663002: Add an error page for resources blocked via XSS Auditor. (Closed)
Patch Set: Test. Created 4 years 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 function checkIfFrameLocationMatchesSrcAndCallDone(frameId) 1 function checkIfFrameLocationMatchesSrcAndCallDone(frameId)
2 { 2 {
3 if (!window.testRunner) 3 if (!window.testRunner)
4 return; 4 return;
5 5
6 var actualURL = 'unavailable', frame = document.getElementById(frameId); 6 var actualURL = 'unavailable', frame = document.getElementById(frameId);
7 try { 7 try {
8 actualURL = frame.contentWindow.location.href; 8 actualURL = frame.contentWindow.location.href;
9 } 9 }
10 catch (e) { 10 catch (e) {
11 actualURL = '[Location object access threw exception]'; 11 actualURL = '[Location object access threw exception]';
12 } 12 }
13 13
14 if (actualURL != frame.src) 14 if (actualURL != frame.src)
15 alert('URL mismatch: \'' + actualURL + '\' vs. \'' + frame.src + '\''); 15 alert('URL mismatch: \'' + actualURL + '\' vs. \'' + frame.src + '\'');
16 16
17 testRunner.notifyDone(); 17 testRunner.notifyDone();
18 } 18 }
19 19
20 function checkFrameIsCrossOriginAndCallDone(frameId) {
21 if (!window.testRunner)
22 return;
23
24 var actualURL = 'unavailable', frame = document.getElementById(frameId);
25 try {
26 actualURL = frame.contentWindow.location.href;
27 console.log('FAIL: "' + frameId + '" loaded "' + actualURL + '".');
28 }
29 catch (e) {
30 actualURL = '[Location object access threw exception]';
31 console.log('PASS: "' + frameId + '" is cross-origin.');
32 }
33
34 testRunner.notifyDone();
35 }
36
20 function sendRequestFromIFrame(url, params, HTTPMethod, callbackWhenDone) 37 function sendRequestFromIFrame(url, params, HTTPMethod, callbackWhenDone)
21 { 38 {
22 if (!params || !params.length) 39 if (!params || !params.length)
23 return; 40 return;
24 41
25 if (!HTTPMethod) 42 if (!HTTPMethod)
26 HTTPMethod = 'GET'; 43 HTTPMethod = 'GET';
27 44
28 if (document.getElementById('frame')) 45 if (document.getElementById('frame'))
29 document.body.removeChild(document.getElementById('frame')); 46 document.body.removeChild(document.getElementById('frame'));
(...skipping 19 matching lines...) Expand all
49 66
50 67
51 function notifyDoneAfterReceivingLoaded() 68 function notifyDoneAfterReceivingLoaded()
52 { 69 {
53 window.addEventListener("message", function(event) { 70 window.addEventListener("message", function(event) {
54 if (event.data == "loaded") 71 if (event.data == "loaded")
55 testRunner.notifyDone(); 72 testRunner.notifyDone();
56 }, false); 73 }, false);
57 } 74 }
58 75
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698