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