OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function getStyleURL() { | 5 function getStyleURL() { |
6 // This is not a style sheet, but it must still be classified as "stylesheet" | 6 // This is not a style sheet, but it must still be classified as "stylesheet" |
7 // because it is loaded as a style sheet. | 7 // because it is loaded as a style sheet. |
8 return getServerURL('empty.html?as-style'); | 8 return getServerURL('empty.html?as-style'); |
9 } | 9 } |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 | 26 |
27 function getPingURL() { | 27 function getPingURL() { |
28 return getServerURL('empty.html?as-ping'); | 28 return getServerURL('empty.html?as-ping'); |
29 } | 29 } |
30 | 30 |
31 function getBeaconURL() { | 31 function getBeaconURL() { |
32 return getServerURL('empty.html?as-beacon'); | 32 return getServerURL('empty.html?as-beacon'); |
33 } | 33 } |
34 | 34 |
35 function getCSPReportURL() { | |
36 // dont-ignore-me is included so that framework.js does not filter out the | |
37 // request of type "other". | |
38 return getServerURL('csp-violation-dont-ignore-me'); | |
39 } | |
40 | |
41 // A slow URL used for the beacon test, to make sure that the test fails | 35 // A slow URL used for the beacon test, to make sure that the test fails |
42 // deterministically if there is a bug that causes the frameId/tabId to not be | 36 // deterministically if there is a bug that causes the frameId/tabId to not be |
43 // set if the frame is removed during the request. | 37 // set if the frame is removed during the request. |
44 function getSlowURL() { | 38 function getSlowURL() { |
45 return getServerURL('slow?2.718'); | 39 return getServerURL('slow?2.718'); |
46 } | 40 } |
47 | 41 |
48 function getScriptFilter() { | 42 function getScriptFilter() { |
49 // Scripts and worker scripts are internally represented by a different | 43 // Scripts and worker scripts are internally represented by a different |
50 // ResourceType, but they still map to the same public "script" type. | 44 // ResourceType, but they still map to the same public "script" type. |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 | 606 |
613 var frame = document.createElement('iframe'); | 607 var frame = document.createElement('iframe'); |
614 document.body.appendChild(frame); | 608 document.body.appendChild(frame); |
615 frame.contentWindow.onunload = function() { | 609 frame.contentWindow.onunload = function() { |
616 console.log('Going to send beacon...'); | 610 console.log('Going to send beacon...'); |
617 var sentBeacon = frame.contentWindow.navigator.sendBeacon(getSlowURL()); | 611 var sentBeacon = frame.contentWindow.navigator.sendBeacon(getSlowURL()); |
618 chrome.test.assertTrue(sentBeacon); | 612 chrome.test.assertTrue(sentBeacon); |
619 }; | 613 }; |
620 frame.remove(); | 614 frame.remove(); |
621 }, | 615 }, |
622 | |
623 function typeOther_cspreport() { | |
624 expect([ | |
625 { label: 'onBeforeRequest', | |
626 event: 'onBeforeRequest', | |
627 details: { | |
628 type: 'csp_report', | |
629 method: 'POST', | |
630 url: getCSPReportURL(), | |
631 frameUrl: 'unknown frame URL', | |
632 frameId: 1, | |
633 parentFrameId: 0, | |
634 tabId: 1, | |
635 } | |
636 }, | |
637 { label: 'onBeforeSendHeaders', | |
638 event: 'onBeforeSendHeaders', | |
639 details: { | |
640 type: 'csp_report', | |
641 method: 'POST', | |
642 url: getCSPReportURL(), | |
643 frameId: 1, | |
644 parentFrameId: 0, | |
645 tabId: 1, | |
646 }, | |
647 }, | |
648 { label: 'onSendHeaders', | |
649 event: 'onSendHeaders', | |
650 details: { | |
651 type: 'csp_report', | |
652 method: 'POST', | |
653 url: getCSPReportURL(), | |
654 frameId: 1, | |
655 parentFrameId: 0, | |
656 tabId: 1, | |
657 }, | |
658 }, | |
659 { label: 'onHeadersReceived', | |
660 event: 'onHeadersReceived', | |
661 details: { | |
662 type: 'csp_report', | |
663 method: 'POST', | |
664 url: getCSPReportURL(), | |
665 frameId: 1, | |
666 parentFrameId: 0, | |
667 tabId: 1, | |
668 statusLine: 'HTTP/1.1 404 Not Found', | |
669 statusCode: 404, | |
670 }, | |
671 }, | |
672 { label: 'onResponseStarted', | |
673 event: 'onResponseStarted', | |
674 details: { | |
675 type: 'csp_report', | |
676 method: 'POST', | |
677 url: getCSPReportURL(), | |
678 frameId: 1, | |
679 parentFrameId: 0, | |
680 tabId: 1, | |
681 ip: '127.0.0.1', | |
682 fromCache: false, | |
683 statusLine: 'HTTP/1.1 404 Not Found', | |
684 statusCode: 404, | |
685 }, | |
686 }, | |
687 { label: 'onCompleted', | |
688 event: 'onCompleted', | |
689 details: { | |
690 type: 'csp_report', | |
691 method: 'POST', | |
692 url: getCSPReportURL(), | |
693 frameId: 1, | |
694 parentFrameId: 0, | |
695 tabId: 1, | |
696 ip: '127.0.0.1', | |
697 fromCache: false, | |
698 statusLine: 'HTTP/1.1 404 Not Found', | |
699 statusCode: 404, | |
700 }, | |
701 }], | |
702 [['onBeforeRequest', 'onBeforeSendHeaders', 'onSendHeaders', | |
703 'onHeadersReceived', 'onResponseStarted', 'onCompleted']], { | |
704 urls: ['<all_urls>'], types: ['csp_report'] | |
705 }); | |
706 | |
707 var frame = document.createElement('iframe'); | |
708 frame.src = | |
709 getServerURL('extensions/api_test/webrequest/csp/violation.html'); | |
710 document.body.appendChild(frame); | |
711 }, | |
712 ]); | 616 ]); |
OLD | NEW |