| Differences between
and this patch
- Source/WebCore/ChangeLog +33 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2015-10-13  Roopesh Chander  <roop@roopc.net>
2
3
        Content blocking rules should be respected for requests loaded by PingLoader
4
        https://bugs.webkit.org/show_bug.cgi?id=149873
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Tests: http/tests/contentextensions/block-cookies-in-csp-report.html
9
               http/tests/contentextensions/block-cookies-in-image-load-in-onunload.html
10
               http/tests/contentextensions/block-cookies-in-ping.html
11
               http/tests/contentextensions/block-csp-report.html
12
               http/tests/contentextensions/block-image-load-in-onunload.html
13
               http/tests/contentextensions/block-ping.html
14
               http/tests/contentextensions/hide-on-csp-report.html
15
               http/tests/contentextensions/hide-on-ping.html
16
17
        * contentextensions/ContentExtensionActions.h:
18
        * contentextensions/ContentExtensionsBackend.cpp:
19
        (WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRulesForLoad):
20
        (WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRulesForPing):
21
        (WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRules):
22
        * contentextensions/ContentExtensionsBackend.h:
23
        * loader/PingLoader.cpp:
24
        (WebCore::processContentExtensionRulesForPing):
25
        (WebCore::PingLoader::loadImage):
26
        (WebCore::PingLoader::sendPing):
27
        (WebCore::PingLoader::sendViolationReport):
28
        * page/UserContentController.cpp:
29
        (WebCore::UserContentController::processContentExtensionRulesForLoad):
30
        (WebCore::UserContentController::processContentExtensionRulesForPing):
31
        (WebCore::UserContentController::actionsForResourceLoad):
32
        * page/UserContentController.h:
33
1
2015-10-12  Antti Koivisto  <antti@apple.com>
34
2015-10-12  Antti Koivisto  <antti@apple.com>
2
35
3
        Implement iterator for traversing composed DOM
36
        Implement iterator for traversing composed DOM
- Source/WebCore/contentextensions/ContentExtensionActions.h +1 lines
Lines 45-50 enum class ActionType : uint8_t { Source/WebCore/contentextensions/ContentExtensionActions.h_sec1
45
45
46
enum class BlockedStatus {
46
enum class BlockedStatus {
47
    Blocked,
47
    Blocked,
48
    BlockedCookies,
48
    NotBlocked,
49
    NotBlocked,
49
};
50
};
50
    
51
    
- Source/WebCore/contentextensions/ContentExtensionsBackend.cpp -9 / +52 lines
Lines 162-189 BlockedStatus ContentExtensionsBackend:: Source/WebCore/contentextensions/ContentExtensionsBackend.cpp_sec1
162
    }
162
    }
163
163
164
    ResourceLoadInfo resourceLoadInfo = { request.url(), mainDocumentURL, resourceType };
164
    ResourceLoadInfo resourceLoadInfo = { request.url(), mainDocumentURL, resourceType };
165
    Vector<ContentExtensions::Action> actions = actionsForResourceLoad(resourceLoadInfo);
165
166
    auto blockedStatus = processContentExtensionRules(resourceLoadInfo, currentDocument, &initiatingDocumentLoader);
167
    
168
    if (blockedStatus == BlockedStatus::Blocked) {
169
        if (currentDocument)
170
            currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker prevented frame displaying ", mainDocumentURL.string(), " from loading a resource from ", request.url().string()));
171
    } else if (blockedStatus == BlockedStatus::BlockedCookies) {
172
        request.setAllowCookies(false);
173
    }
174
175
    return blockedStatus;
176
}
177
178
BlockedStatus ContentExtensionsBackend::processContentExtensionRulesForPing(const URL& url, ResourceType resourceType, const DocumentLoader& initiatingDocumentLoader)
179
{
180
    ASSERT_WITH_MESSAGE(resourceType != ResourceType::Document, "Loading of a document cannot be done with a ping");
181
182
    Document* currentDocument = nullptr;
183
    URL mainDocumentURL;
184
185
    if (Frame* frame = initiatingDocumentLoader.frame()) {
186
        currentDocument = frame->document();
187
        if (Document* mainDocument = frame->mainFrame().document())
188
            mainDocumentURL = mainDocument->url();
189
    }
190
191
    ResourceLoadInfo resourceLoadInfo = { url, mainDocumentURL, resourceType };
192
193
    auto blockedStatus = processContentExtensionRules(resourceLoadInfo, currentDocument, nullptr);
194
195
    if (blockedStatus == BlockedStatus::Blocked) {
196
        if (currentDocument)
197
            currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker prevented frame displaying ", resourceLoadInfo.mainDocumentURL.string(), " from pinging to ", resourceLoadInfo.resourceURL.string()));
198
    }
199
200
    return blockedStatus;
201
}
202
203
BlockedStatus ContentExtensionsBackend::processContentExtensionRules(const ResourceLoadInfo& resourceLoadInfo, Document* currentDocument, DocumentLoader* initiatingDocumentLoader)
204
{
205
    auto actions = actionsForResourceLoad(resourceLoadInfo);
166
206
167
    bool willBlockLoad = false;
207
    bool willBlockLoad = false;
208
    bool willBlockCookies = false;
209
168
    for (const auto& action : actions) {
210
    for (const auto& action : actions) {
169
        switch (action.type()) {
211
        switch (action.type()) {
170
        case ContentExtensions::ActionType::BlockLoad:
212
        case ContentExtensions::ActionType::BlockLoad:
171
            willBlockLoad = true;
213
            willBlockLoad = true;
172
            break;
214
            break;
173
        case ContentExtensions::ActionType::BlockCookies:
215
        case ContentExtensions::ActionType::BlockCookies:
174
            request.setAllowCookies(false);
216
            willBlockCookies = true;
175
            break;
217
            break;
176
        case ContentExtensions::ActionType::CSSDisplayNoneSelector:
218
        case ContentExtensions::ActionType::CSSDisplayNoneSelector: {
177
            if (resourceType == ResourceType::Document)
219
            if (resourceLoadInfo.type == ResourceType::Document && initiatingDocumentLoader)
178
                initiatingDocumentLoader.addPendingContentExtensionDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID());
220
                initiatingDocumentLoader->addPendingContentExtensionDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID());
179
            else if (currentDocument)
221
            else if (currentDocument)
180
                currentDocument->extensionStyleSheets().addDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID());
222
                currentDocument->extensionStyleSheets().addDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID());
181
            break;
223
            break;
224
        }
182
        case ContentExtensions::ActionType::CSSDisplayNoneStyleSheet: {
225
        case ContentExtensions::ActionType::CSSDisplayNoneStyleSheet: {
183
            StyleSheetContents* styleSheetContents = globalDisplayNoneStyleSheet(action.stringArgument());
226
            StyleSheetContents* styleSheetContents = globalDisplayNoneStyleSheet(action.stringArgument());
184
            if (styleSheetContents) {
227
            if (styleSheetContents) {
185
                if (resourceType == ResourceType::Document)
228
                if (resourceLoadInfo.type == ResourceType::Document && initiatingDocumentLoader)
186
                    initiatingDocumentLoader.addPendingContentExtensionSheet(action.stringArgument(), *styleSheetContents);
229
                    initiatingDocumentLoader->addPendingContentExtensionSheet(action.stringArgument(), *styleSheetContents);
187
                else if (currentDocument)
230
                else if (currentDocument)
188
                    currentDocument->extensionStyleSheets().maybeAddContentExtensionSheet(action.stringArgument(), *styleSheetContents);
231
                    currentDocument->extensionStyleSheets().maybeAddContentExtensionSheet(action.stringArgument(), *styleSheetContents);
189
            }
232
            }
Lines 196-204 BlockedStatus ContentExtensionsBackend:: Source/WebCore/contentextensions/ContentExtensionsBackend.cpp_sec2
196
    }
239
    }
197
240
198
    if (willBlockLoad) {
241
    if (willBlockLoad) {
199
        if (currentDocument)
200
            currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker prevented frame displaying ", mainDocumentURL.string(), " from loading a resource from ", request.url().string()));
201
        return BlockedStatus::Blocked;
242
        return BlockedStatus::Blocked;
243
    } else if (willBlockCookies) {
244
        return BlockedStatus::BlockedCookies;
202
    }
245
    }
203
    return BlockedStatus::NotBlocked;
246
    return BlockedStatus::NotBlocked;
204
}
247
}
- Source/WebCore/contentextensions/ContentExtensionsBackend.h +3 lines
Lines 66-75 public: Source/WebCore/contentextensions/ContentExtensionsBackend.h_sec1
66
    WEBCORE_EXPORT StyleSheetContents* globalDisplayNoneStyleSheet(const String& identifier) const;
66
    WEBCORE_EXPORT StyleSheetContents* globalDisplayNoneStyleSheet(const String& identifier) const;
67
67
68
    BlockedStatus processContentExtensionRulesForLoad(ResourceRequest&, ResourceType, DocumentLoader& initiatingDocumentLoader);
68
    BlockedStatus processContentExtensionRulesForLoad(ResourceRequest&, ResourceType, DocumentLoader& initiatingDocumentLoader);
69
    BlockedStatus processContentExtensionRulesForPing(const URL&, ResourceType, const DocumentLoader& initiatingDocumentLoader);
69
70
70
    static const String& displayNoneCSSRule();
71
    static const String& displayNoneCSSRule();
71
72
72
private:
73
private:
74
    BlockedStatus processContentExtensionRules(const ResourceLoadInfo&, Document*, DocumentLoader* initiatingDocumentLoader);
75
73
    HashMap<String, RefPtr<ContentExtension>> m_contentExtensions;
76
    HashMap<String, RefPtr<ContentExtension>> m_contentExtensions;
74
};
77
};
75
78
- Source/WebCore/loader/PingLoader.cpp -1 / +60 lines
Lines 44-59 Source/WebCore/loader/PingLoader.cpp_sec1
44
#include "PlatformStrategies.h"
44
#include "PlatformStrategies.h"
45
#include "ProgressTracker.h"
45
#include "ProgressTracker.h"
46
#include "ResourceHandle.h"
46
#include "ResourceHandle.h"
47
#include "ResourceLoadInfo.h"
47
#include "ResourceRequest.h"
48
#include "ResourceRequest.h"
48
#include "ResourceResponse.h"
49
#include "ResourceResponse.h"
49
#include "SecurityOrigin.h"
50
#include "SecurityOrigin.h"
50
#include "SecurityPolicy.h"
51
#include "SecurityPolicy.h"
52
#include "UserContentController.h"
51
#include <wtf/text/CString.h>
53
#include <wtf/text/CString.h>
52
54
53
namespace WebCore {
55
namespace WebCore {
54
56
57
#if ENABLE(CONTENT_EXTENSIONS)
58
static ContentExtensions::BlockedStatus processContentExtensionRulesForPing(const Frame& frame, const URL& url, ResourceType resourceType) {
59
    if (DocumentLoader* documentLoader = frame.loader().documentLoader()) {
60
        if (Page* page = frame.page()) {
61
            if (UserContentController* controller = page->userContentController()) {
62
                return controller->processContentExtensionRulesForPing(url, resourceType, *documentLoader);
63
            }
64
        }
65
    }
66
    return ContentExtensions::BlockedStatus::NotBlocked;
67
}
68
#endif
69
55
void PingLoader::loadImage(Frame& frame, const URL& url)
70
void PingLoader::loadImage(Frame& frame, const URL& url)
56
{
71
{
72
    bool shouldDisallowCookies = false;
73
74
#if ENABLE(CONTENT_EXTENSIONS)
75
    auto pingBlockStatus = processContentExtensionRulesForPing(frame, url, ResourceType::Image);
76
    if (pingBlockStatus == ContentExtensions::BlockedStatus::Blocked) {
77
        return;
78
    } else if (pingBlockStatus == ContentExtensions::BlockedStatus::BlockedCookies) {
79
        shouldDisallowCookies = true;
80
    }
81
#endif
82
57
    if (!frame.document()->securityOrigin()->canDisplay(url)) {
83
    if (!frame.document()->securityOrigin()->canDisplay(url)) {
58
        FrameLoader::reportLocalLoadFailed(&frame, url);
84
        FrameLoader::reportLocalLoadFailed(&frame, url);
59
        return;
85
        return;
Lines 66-77 void PingLoader::loadImage(Frame& frame, Source/WebCore/loader/PingLoader.cpp_sec2
66
        request.setHTTPReferrer(referrer);
92
        request.setHTTPReferrer(referrer);
67
    frame.loader().addExtraFieldsToSubresourceRequest(request);
93
    frame.loader().addExtraFieldsToSubresourceRequest(request);
68
94
95
    if (shouldDisallowCookies) {
96
        request.setAllowCookies(false);
97
    }
98
69
    startPingLoad(frame, request);
99
    startPingLoad(frame, request);
70
}
100
}
71
101
72
// http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing
102
// http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing
73
void PingLoader::sendPing(Frame& frame, const URL& pingURL, const URL& destinationURL)
103
void PingLoader::sendPing(Frame& frame, const URL& pingURL, const URL& destinationURL)
74
{
104
{
105
    bool shouldDisallowCookies = false;
106
107
#if ENABLE(CONTENT_EXTENSIONS)
108
    auto pingBlockStatus = processContentExtensionRulesForPing(frame, pingURL, ResourceType::Raw);
109
    if (pingBlockStatus == ContentExtensions::BlockedStatus::Blocked) {
110
        return;
111
    } else if (pingBlockStatus == ContentExtensions::BlockedStatus::BlockedCookies) {
112
        shouldDisallowCookies = true;
113
    }
114
#endif
115
75
    ResourceRequest request(pingURL);
116
    ResourceRequest request(pingURL);
76
    request.setHTTPMethod("POST");
117
    request.setHTTPMethod("POST");
77
    request.setHTTPContentType("text/ping");
118
    request.setHTTPContentType("text/ping");
Lines 92-107 void PingLoader::sendPing(Frame& frame, Source/WebCore/loader/PingLoader.cpp_sec3
92
        }
133
        }
93
    }
134
    }
94
135
136
    if (shouldDisallowCookies) {
137
        request.setAllowCookies(false);
138
    }
139
95
    startPingLoad(frame, request);
140
    startPingLoad(frame, request);
96
}
141
}
97
142
98
void PingLoader::sendViolationReport(Frame& frame, const URL& reportURL, PassRefPtr<FormData> report)
143
void PingLoader::sendViolationReport(Frame& frame, const URL& reportURL, PassRefPtr<FormData> report)
99
{
144
{
145
    bool shouldDisallowCookies = false;
146
147
#if ENABLE(CONTENT_EXTENSIONS)
148
    auto pingBlockStatus = processContentExtensionRulesForPing(frame, reportURL, ResourceType::Raw);
149
    if (pingBlockStatus == ContentExtensions::BlockedStatus::Blocked) {
150
        return;
151
    } else if (pingBlockStatus == ContentExtensions::BlockedStatus::BlockedCookies) {
152
        shouldDisallowCookies = true;
153
    }
154
#endif
155
100
    ResourceRequest request(reportURL);
156
    ResourceRequest request(reportURL);
101
    request.setHTTPMethod("POST");
157
    request.setHTTPMethod("POST");
102
    request.setHTTPContentType("application/json");
158
    request.setHTTPContentType("application/json");
103
    request.setHTTPBody(report);
159
    request.setHTTPBody(report);
104
    request.setAllowCookies(frame.document()->securityOrigin()->isSameSchemeHostPort(SecurityOrigin::create(reportURL).ptr()));
160
    bool isSameSchemeHostPort = frame.document()->securityOrigin()->isSameSchemeHostPort(SecurityOrigin::create(reportURL).ptr());
161
    if (!isSameSchemeHostPort || shouldDisallowCookies) {
162
        request.setAllowCookies(false);
163
    }
105
    frame.loader().addExtraFieldsToSubresourceRequest(request);
164
    frame.loader().addExtraFieldsToSubresourceRequest(request);
106
165
107
    String referrer = SecurityPolicy::generateReferrerHeader(frame.document()->referrerPolicy(), reportURL, frame.loader().outgoingReferrer());
166
    String referrer = SecurityPolicy::generateReferrerHeader(frame.document()->referrerPolicy(), reportURL, frame.loader().outgoingReferrer());
- Source/WebCore/page/UserContentController.cpp +11 lines
Lines 219-224 ContentExtensions::BlockedStatus UserCon Source/WebCore/page/UserContentController.cpp_sec1
219
    return m_contentExtensionBackend->processContentExtensionRulesForLoad(request, resourceType, initiatingDocumentLoader);
219
    return m_contentExtensionBackend->processContentExtensionRulesForLoad(request, resourceType, initiatingDocumentLoader);
220
}
220
}
221
221
222
ContentExtensions::BlockedStatus UserContentController::processContentExtensionRulesForPing(const URL& url, ResourceType resourceType, const DocumentLoader& initiatingDocumentLoader)
223
{
224
    if (!m_contentExtensionBackend)
225
        return ContentExtensions::BlockedStatus::NotBlocked;
226
227
    if (!initiatingDocumentLoader.userContentExtensionsEnabled())
228
        return ContentExtensions::BlockedStatus::NotBlocked;
229
230
    return m_contentExtensionBackend->processContentExtensionRulesForPing(url, resourceType, initiatingDocumentLoader);
231
}
232
222
Vector<ContentExtensions::Action> UserContentController::actionsForResourceLoad(const ResourceLoadInfo& resourceLoadInfo, DocumentLoader& initiatingDocumentLoader)
233
Vector<ContentExtensions::Action> UserContentController::actionsForResourceLoad(const ResourceLoadInfo& resourceLoadInfo, DocumentLoader& initiatingDocumentLoader)
223
{
234
{
224
    if (!m_contentExtensionBackend)
235
    if (!m_contentExtensionBackend)
- Source/WebCore/page/UserContentController.h +1 lines
Lines 94-99 public: Source/WebCore/page/UserContentController.h_sec1
94
    WEBCORE_EXPORT void removeAllUserContentExtensions();
94
    WEBCORE_EXPORT void removeAllUserContentExtensions();
95
95
96
    ContentExtensions::BlockedStatus processContentExtensionRulesForLoad(ResourceRequest&, ResourceType, DocumentLoader& initiatingDocumentLoader);
96
    ContentExtensions::BlockedStatus processContentExtensionRulesForLoad(ResourceRequest&, ResourceType, DocumentLoader& initiatingDocumentLoader);
97
    ContentExtensions::BlockedStatus processContentExtensionRulesForPing(const URL&, ResourceType, const DocumentLoader& initiatingDocumentLoader);
97
    Vector<ContentExtensions::Action> actionsForResourceLoad(const ResourceLoadInfo&, DocumentLoader& initiatingDocumentLoader);
98
    Vector<ContentExtensions::Action> actionsForResourceLoad(const ResourceLoadInfo&, DocumentLoader& initiatingDocumentLoader);
98
#endif
99
#endif
99
100
- LayoutTests/ChangeLog +39 lines
Lines 1-3 LayoutTests/ChangeLog_sec1
1
2015-10-13  Roopesh Chander  <roop@roopc.net>
2
3
        Tests to ensure content blocking rules are respected for requests loaded by PingLoader
4
        https://bugs.webkit.org/show_bug.cgi?id=149873
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * http/tests/contentextensions/block-cookies-in-csp-report-expected.txt: Added.
9
        * http/tests/contentextensions/block-cookies-in-csp-report.html: Added.
10
        * http/tests/contentextensions/block-cookies-in-csp-report.html.json: Added.
11
        * http/tests/contentextensions/block-cookies-in-image-load-in-onunload-expected.txt: Added.
12
        * http/tests/contentextensions/block-cookies-in-image-load-in-onunload.html: Added.
13
        * http/tests/contentextensions/block-cookies-in-image-load-in-onunload.html.json: Added.
14
        * http/tests/contentextensions/block-cookies-in-ping-expected.txt: Added.
15
        * http/tests/contentextensions/block-cookies-in-ping.html: Added.
16
        * http/tests/contentextensions/block-cookies-in-ping.html.json: Added.
17
        * http/tests/contentextensions/block-csp-report-expected.txt: Added.
18
        * http/tests/contentextensions/block-csp-report.html: Added.
19
        * http/tests/contentextensions/block-csp-report.html.json: Added.
20
        * http/tests/contentextensions/block-image-load-in-onunload-expected.txt: Added.
21
        * http/tests/contentextensions/block-image-load-in-onunload.html: Added.
22
        * http/tests/contentextensions/block-image-load-in-onunload.html.json: Added.
23
        * http/tests/contentextensions/block-ping-expected.txt: Added.
24
        * http/tests/contentextensions/block-ping.html: Added.
25
        * http/tests/contentextensions/block-ping.html.json: Added.
26
        * http/tests/contentextensions/hide-on-csp-report-expected.txt: Added.
27
        * http/tests/contentextensions/hide-on-csp-report.html: Added.
28
        * http/tests/contentextensions/hide-on-csp-report.html.json: Added.
29
        * http/tests/contentextensions/hide-on-ping-expected.txt: Added.
30
        * http/tests/contentextensions/hide-on-ping.html: Added.
31
        * http/tests/contentextensions/hide-on-ping.html.json: Added.
32
        * http/tests/contentextensions/resources/check-ping.html: Added.
33
        * http/tests/contentextensions/resources/delete-ping.php: Added.
34
        * http/tests/contentextensions/resources/get-ping-data.php: Added.
35
        * http/tests/contentextensions/resources/load-in-frame.php: Added.
36
        * http/tests/contentextensions/resources/ping-file-path.php: Added.
37
        * http/tests/contentextensions/resources/redirect.php: Added.
38
        * http/tests/contentextensions/resources/save-ping.php: Added.
39
1
2015-10-11  Myles C. Maxfield  <mmaxfield@apple.com>
40
2015-10-11  Myles C. Maxfield  <mmaxfield@apple.com>
2
41
3
        Test font-variant-* and font-feature-settings with mocked preinstalled fonts
42
        Test font-variant-* and font-feature-settings with mocked preinstalled fonts
- LayoutTests/http/tests/contentextensions/block-cookies-in-csp-report-expected.txt +11 lines
Line 0 LayoutTests/http/tests/contentextensions/block-cookies-in-csp-report-expected.txt_sec1
1
CONSOLE MESSAGE: Refused to load the image 'http://localhost/foo.png' because it violates the following Content Security Policy directive: "img-src 'self'".
2
3
This test creates a CSP violation report, but the report URL matches a 'block-cookie' rule. 
4
5
6
7
--------
8
Frame: 'result_frame'
9
--------
10
Ping received.
11
No cookies in ping.
- LayoutTests/http/tests/contentextensions/block-cookies-in-csp-report.html +40 lines
Line 0 LayoutTests/http/tests/contentextensions/block-cookies-in-csp-report.html_sec1
1
<head>
2
<meta http-equiv="Content-Security-Policy" content="img-src 'self'; report-uri /contentextensions/resources/save-ping.php?test=contentextensions-block-cookies-in-csp-report">
3
<script>
4
if (window.testRunner) {
5
    testRunner.dumpAsText();
6
    testRunner.dumpChildFramesAsText();
7
    testRunner.waitUntilDone();
8
}
9
10
function deletePing() {
11
    var deletePingContainer = document.getElementById("delete_ping_container");
12
    deletePingContainer.innerHTML = '<img src="resources/delete-ping.php?test=contentextensions-block-cookies-in-csp-report" onerror="loadCrossDomainImage();">';
13
}
14
15
function loadCrossDomainImage() {
16
    // Trying to load an image from a different port
17
    // will result in a CSP violation.
18
    var img = new Image(1, 1);
19
    img.src = "http://localhost/foo.png";
20
    showPingResult();
21
}
22
23
function showPingResult() {
24
    var iframe = document.getElementById("result_frame");
25
    iframe.onload = function() {
26
        if (window.testRunner) { testRunner.notifyDone(); }
27
    }
28
    iframe.src = "resources/get-ping-data.php?test=contentextensions-block-cookies-in-csp-report";
29
}
30
</script>
31
</head>
32
33
<body>
34
This test creates a CSP violation report, but the report URL matches a 'block-cookie' rule.
35
<img src="/cookies/resources/cookie-utility.php?queryfunction=setFooCookie"
36
    onerror="deletePing();">
37
<div id="delete_ping_container"></div>
38
<iframe id="result_frame"><!-- Will contain ping data received by server --></iframe>
39
</body>
40
- LayoutTests/http/tests/contentextensions/block-cookies-in-csp-report.html.json +10 lines
Line 0 LayoutTests/http/tests/contentextensions/block-cookies-in-csp-report.html.json_sec1
1
[
2
    {
3
        "trigger": {
4
            "url-filter": "save-ping.php"
5
        },
6
        "action": {
7
            "type": "block-cookies"
8
        }
9
    }
10
]
- LayoutTests/http/tests/contentextensions/block-cookies-in-image-load-in-onunload-expected.txt +3 lines
Line 0 LayoutTests/http/tests/contentextensions/block-cookies-in-image-load-in-onunload-expected.txt_sec1
1
main frame - has 1 onunload handler(s)
2
Ping received.
3
No cookies in ping.
- LayoutTests/http/tests/contentextensions/block-cookies-in-image-load-in-onunload.html +35 lines
Line 0 LayoutTests/http/tests/contentextensions/block-cookies-in-image-load-in-onunload.html_sec1
1
<head>
2
<script>
3
if (window.testRunner) {
4
    testRunner.dumpAsText();
5
    testRunner.waitUntilDone();
6
}
7
8
function deletePing() {
9
    var deletePingContainer = document.getElementById("delete_ping_container");
10
    deletePingContainer.innerHTML = '<img src="resources/delete-ping.php?test=contentextensions-block-cookies-in-image-load-in-onunload" onerror="loadNextPage();">';
11
}
12
13
function loadNextPage() {
14
    // Navigating to another location invokes the unload handler
15
    location.href = "resources/redirect.php?to=" + 
16
                        encodeURIComponent(
17
                        "/contentextensions/resources/get-ping-data.php?" + 
18
                        "test=contentextensions-block-cookies-in-image-load-in-onunload&" +
19
                        "end_test=1");
20
}
21
22
function loadImage() {
23
    var img = new Image(1, 1);
24
    img.src = "resources/save-ping.php?test=contentextensions-block-cookies-in-image-load-in-onunload";
25
}
26
</script>
27
</head>
28
29
<body onunload="loadImage();">
30
This test sets a cookie, then loads an image in onunload, where the image URL matches a 'block-cookie' rule.
31
<img src="http://127.0.0.1:8000/cookies/resources/cookie-utility.php?queryfunction=setFooCookie"
32
    onerror="deletePing();">
33
<div id="delete_ping_container"></div>
34
</body>
35
- LayoutTests/http/tests/contentextensions/block-cookies-in-image-load-in-onunload.html.json +10 lines
Line 0 LayoutTests/http/tests/contentextensions/block-cookies-in-image-load-in-onunload.html.json_sec1
1
[
2
    {
3
        "trigger": {
4
            "url-filter": "save-ping.php"
5
        },
6
        "action": {
7
            "type": "block-cookies"
8
        }
9
    }
10
]
- LayoutTests/http/tests/contentextensions/block-cookies-in-ping-expected.txt +12 lines
Line 0 LayoutTests/http/tests/contentextensions/block-cookies-in-ping-expected.txt_sec1
1
This test sets a cookie, then follows a link with a ping attribute where the ping URL matches a 'block-cookie' rule.   
2
3
--------
4
Frame: 'link_frame'
5
--------
6
Link with ping was clicked.
7
8
--------
9
Frame: 'result_frame'
10
--------
11
Ping received.
12
No cookies in ping.
- LayoutTests/http/tests/contentextensions/block-cookies-in-ping.html +55 lines
Line 0 LayoutTests/http/tests/contentextensions/block-cookies-in-ping.html_sec1
1
<head>
2
<script>
3
if (window.testRunner) {
4
    testRunner.dumpAsText();
5
    testRunner.dumpChildFramesAsText();
6
    testRunner.overridePreference("WebKitHyperlinkAuditingEnabled", 1);
7
    testRunner.waitUntilDone();
8
}
9
10
function loadLinkWithPing() {
11
    var iframe = document.getElementById("link_frame");
12
    var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
13
    iframeDoc.write('' +
14
        '<img src="resources/delete-ping.php?test=contentextensions-block-cookies-in-ping" ' + 
15
            'onerror="parent.clickOnLinkWithPing();">' +
16
        '<a id="a" ' +
17
            'href="resources/check-ping.html" ' + // check-ping.html calls showPingResult()
18
            'ping="resources/save-ping.php?test=contentextensions-block-cookies-in-ping"> ' +
19
            'Link with ping' +
20
        '</a>'
21
        
22
    );
23
}
24
25
function clickOnLinkWithPing() {
26
    var iframe = document.getElementById("link_frame");
27
    var iframeDoc = iframe.contentDocument;
28
    if (window.eventSender) {
29
        var a = iframeDoc.getElementById("a");
30
        var x = iframe.offsetLeft + a.offsetLeft + 2;
31
        var y = iframe.offsetTop + a.offsetTop + 2;
32
        eventSender.mouseMoveTo(x, y);
33
        eventSender.mouseDown();
34
        eventSender.mouseUp();
35
    }
36
}
37
38
function showPingResult() {
39
    var iframe = document.getElementById("result_frame");
40
    iframe.onload = function() {
41
        if (window.testRunner) { testRunner.notifyDone() }
42
    }
43
    iframe.src = "resources/get-ping-data.php?test=contentextensions-block-cookies-in-ping";
44
}
45
</script>
46
</head>
47
48
<body>
49
This test sets a cookie, then follows a link with a ping attribute where the ping URL matches a 'block-cookie' rule.
50
<img src="http://localhost:8000/cookies/resources/cookie-utility.php?queryfunction=setFooCookie"
51
    onerror="loadLinkWithPing();">
52
<iframe id="link_frame"><!-- Will contain link with ping --></iframe>
53
<iframe id="result_frame"><!-- Will contain ping data received by server --></iframe>
54
</body>
55
- LayoutTests/http/tests/contentextensions/block-cookies-in-ping.html.json +10 lines
Line 0 LayoutTests/http/tests/contentextensions/block-cookies-in-ping.html.json_sec1
1
[
2
    {
3
        "trigger": {
4
            "url-filter": "save-ping.php"
5
        },
6
        "action": {
7
            "type": "block-cookies"
8
        }
9
    }
10
]
- LayoutTests/http/tests/contentextensions/block-csp-report-expected.txt +9 lines
Line 0 LayoutTests/http/tests/contentextensions/block-csp-report-expected.txt_sec1
1
CONSOLE MESSAGE: Refused to load the image 'http://localhost/foo.png' because it violates the following Content Security Policy directive: "img-src 'self'".
2
3
CONSOLE MESSAGE: line 34: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/block-csp-report.html from pinging to http://localhost:8000/contentextensions/resources/save-ping.php?test=contentextensions-block-csp-report
4
This test creates a CSP violation report, but the report URL matches a 'block' rule.  
5
6
--------
7
Frame: 'result_frame'
8
--------
9
Ping not received - timed out.
- LayoutTests/http/tests/contentextensions/block-csp-report.html +37 lines
Line 0 LayoutTests/http/tests/contentextensions/block-csp-report.html_sec1
1
<head>
2
<meta http-equiv="Content-Security-Policy" content="img-src 'self'; report-uri http://localhost:8000/contentextensions/resources/save-ping.php?test=contentextensions-block-csp-report">
3
<script>
4
if (window.testRunner) {
5
    testRunner.dumpAsText();
6
    testRunner.dumpChildFramesAsText();
7
    testRunner.waitUntilDone();
8
}
9
10
function loadCrossDomainImage() {
11
    // Trying to load an image from a different port
12
    // will result in a CSP violation.
13
    var img = new Image(1, 1);
14
    img.src = "http://localhost/foo.png";
15
    showPingResult();
16
}
17
18
function showPingResult() {
19
    var iframe = document.getElementById("result_frame");
20
    iframe.onload = function() {
21
        if (window.testRunner) { testRunner.notifyDone(); }
22
    }
23
    iframe.src = "resources/get-ping-data.php?test=contentextensions-block-csp-report&timeout_ms=1000";
24
    // Why timeout_ms=1000:
25
    // To pass the test, the ping shouldn't arrive, so we need to
26
    // timeout at some point. We don't have to wait too long because
27
    // the console message can tell us whether the ping was blocked.
28
}
29
</script>
30
</head>
31
32
<body>
33
This test creates a CSP violation report, but the report URL matches a 'block' rule.
34
<img src="resources/delete-ping.php?test=contentextensions-block-csp-report" onerror="loadCrossDomainImage();">
35
<iframe id="result_frame"><!-- Will contain ping data received by server --></iframe>
36
</body>
37
- LayoutTests/http/tests/contentextensions/block-csp-report.html.json +10 lines
Line 0 LayoutTests/http/tests/contentextensions/block-csp-report.html.json_sec1
1
[
2
    {
3
        "trigger": {
4
            "url-filter": "save-ping.php"
5
        },
6
        "action": {
7
            "type": "block"
8
        }
9
    }
10
]
- LayoutTests/http/tests/contentextensions/block-image-load-in-onunload-expected.txt +3 lines
Line 0 LayoutTests/http/tests/contentextensions/block-image-load-in-onunload-expected.txt_sec1
1
main frame - has 1 onunload handler(s)
2
CONSOLE MESSAGE: line 29: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/block-image-load-in-onunload.html from pinging to http://127.0.0.1:8000/contentextensions/resources/save-ping.php?test=contentextensions-block-image-load-in-onunload
3
Ping not received - timed out.
- LayoutTests/http/tests/contentextensions/block-image-load-in-onunload.html +33 lines
Line 0 LayoutTests/http/tests/contentextensions/block-image-load-in-onunload.html_sec1
1
<head>
2
<script>
3
if (window.testRunner) {
4
    testRunner.dumpAsText();
5
    testRunner.waitUntilDone();
6
}
7
8
function loadNextPage() {
9
    // Navigating to another location invokes the unload handler
10
    location.href = "resources/redirect.php?to=" + 
11
                        encodeURIComponent(
12
                        "/contentextensions/resources/get-ping-data.php?" + 
13
                        "test=contentextensions-block-image-load-in-onunload&" +
14
                        "timeout_ms=1000&" +
15
                        "end_test=1");
16
    // Why timeout_ms=1000:
17
    // To pass the test, the ping shouldn't arrive, so we need to
18
    // timeout at some point. We don't have to wait too long because
19
    // the console message can tell us whether the ping was blocked.
20
}
21
22
function loadImage() {
23
    var img = new Image(1, 1);
24
    img.src = "resources/save-ping.php?test=contentextensions-block-image-load-in-onunload";
25
}
26
</script>
27
</head>
28
29
<body onunload="loadImage();">
30
This test loads an image in onunload, where the image URL matches a 'block' rule.
31
<img src="resources/delete-ping.php?test=contentextensions-block-image-load-in-onunload" onerror="loadNextPage();">
32
</body>
33
- LayoutTests/http/tests/contentextensions/block-image-load-in-onunload.html.json +10 lines
Line 0 LayoutTests/http/tests/contentextensions/block-image-load-in-onunload.html.json_sec1
1
[
2
    {
3
        "trigger": {
4
            "url-filter": "save-ping.php"
5
        },
6
        "action": {
7
            "type": "block"
8
        }
9
    }
10
]
- LayoutTests/http/tests/contentextensions/block-ping-expected.txt +12 lines
Line 0 LayoutTests/http/tests/contentextensions/block-ping-expected.txt_sec1
1
CONSOLE MESSAGE: line 34: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/block-ping.html from pinging to http://127.0.0.1:8000/contentextensions/resources/save-ping.php?test=contentextensions-block-ping
2
This test follows a link with a ping attribute where the ping URL matches a 'block' rule.  
3
4
--------
5
Frame: 'link_frame'
6
--------
7
Link with ping was clicked.
8
9
--------
10
Frame: 'result_frame'
11
--------
12
Ping not received - timed out.
- LayoutTests/http/tests/contentextensions/block-ping.html +57 lines
Line 0 LayoutTests/http/tests/contentextensions/block-ping.html_sec1
1
<head>
2
<script>
3
if (window.testRunner) {
4
    testRunner.dumpAsText();
5
    testRunner.dumpChildFramesAsText();
6
    testRunner.overridePreference("WebKitHyperlinkAuditingEnabled", 1);
7
    testRunner.waitUntilDone();
8
}
9
10
function loadLinkWithPing() {
11
    var iframe = document.getElementById("link_frame");
12
    var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
13
    iframeDoc.write('' +
14
        '<img src="resources/delete-ping.php?test=contentextensions-block-ping" ' + 
15
            'onerror="parent.clickOnLinkWithPing();">' +
16
        '<a id="a" ' +
17
            'href="resources/check-ping.html" ' + // check-ping.html calls showPingResult()
18
            'ping="resources/save-ping.php?test=contentextensions-block-ping"> ' +
19
            'Link with ping' +
20
        '</a>'
21
        
22
    );
23
}
24
25
function clickOnLinkWithPing() {
26
    var iframe = document.getElementById("link_frame");
27
    var iframeDoc = iframe.contentDocument;
28
    if (window.eventSender) {
29
        var a = iframeDoc.getElementById("a");
30
        var x = iframe.offsetLeft + a.offsetLeft + 2;
31
        var y = iframe.offsetTop + a.offsetTop + 2;
32
        eventSender.mouseMoveTo(x, y);
33
        eventSender.mouseDown();
34
        eventSender.mouseUp();
35
    }
36
}
37
38
function showPingResult() {
39
    var iframe = document.getElementById("result_frame");
40
    iframe.onload = function() {
41
        if (window.testRunner) { testRunner.notifyDone(); }
42
    }
43
    iframe.src = "resources/get-ping-data.php?test=contentextensions-block-ping&timeout_ms=1000";
44
    // Why timeout_ms=1000:
45
    // To pass the test, the ping shouldn't arrive, so we need to
46
    // timeout at some point. We don't have to wait too long because
47
    // the console message can tell us whether the ping was blocked.
48
}
49
</script>
50
</head>
51
52
<body onload="loadLinkWithPing();">
53
This test follows a link with a ping attribute where the ping URL matches a 'block' rule.
54
<iframe id="link_frame"><!-- Will contain link with ping --></iframe>
55
<iframe id="result_frame"><!-- Will contain ping data received by server --></iframe>
56
</body>
57
- LayoutTests/http/tests/contentextensions/block-ping.html.json +10 lines
Line 0 LayoutTests/http/tests/contentextensions/block-ping.html.json_sec1
1
[
2
    {
3
        "trigger": {
4
            "url-filter": "save-ping.php"
5
        },
6
        "action": {
7
            "type": "block"
8
        }
9
    }
10
]
- LayoutTests/http/tests/contentextensions/hide-on-csp-report-expected.txt +12 lines
Line 0 LayoutTests/http/tests/contentextensions/hide-on-csp-report-expected.txt_sec1
1
CONSOLE MESSAGE: Refused to load the image 'http://localhost/foo.png' because it violates the following Content Security Policy directive: "img-src 'self'".
2
3
This test creates a CSP violation report, but the report URL matches a 'css-display-none' rule.
4
This text should remain visible.
5
6
 
7
8
--------
9
Frame: 'result_frame'
10
--------
11
Ping received.
12
No cookies in ping.
- LayoutTests/http/tests/contentextensions/hide-on-csp-report.html +35 lines
Line 0 LayoutTests/http/tests/contentextensions/hide-on-csp-report.html_sec1
1
<head>
2
<meta http-equiv="Content-Security-Policy" content="img-src 'self'; report-uri http://localhost:8000/contentextensions/resources/save-ping.php?test=contentextensions-hide-on-csp-report">
3
<script>
4
if (window.testRunner) {
5
    testRunner.dumpAsText();
6
    testRunner.dumpChildFramesAsText();
7
    testRunner.waitUntilDone();
8
}
9
10
function loadCrossDomainImage() {
11
    // Trying to load an image from a different port
12
    // will result in a CSP violation.
13
    var img = new Image(1, 1);
14
    img.src = "http://localhost/foo.png";
15
    showPingResult();
16
}
17
18
function showPingResult() {
19
    var iframe = document.getElementById("result_frame");
20
    iframe.onload = function() {
21
        if (window.testRunner) { testRunner.notifyDone(); }
22
    }
23
    iframe.src = "resources/get-ping-data.php?test=contentextensions-hide-on-csp-report";
24
}
25
</script>
26
</head>
27
28
<body>
29
This test creates a CSP violation report, but the report URL matches a 'css-display-none' rule.
30
<p class="foo">This text should be hidden once the report is sent.</p>
31
<p class="bar">This text should remain visible.</p>
32
<img src="resources/delete-ping.php?test=contentextensions-hide-on-csp-report" onerror="loadCrossDomainImage();">
33
<iframe id="result_frame"><!-- Will contain ping data received by server --></iframe>
34
</body>
35
- LayoutTests/http/tests/contentextensions/hide-on-csp-report.html.json +11 lines
Line 0 LayoutTests/http/tests/contentextensions/hide-on-csp-report.html.json_sec1
1
[
2
    {
3
        "trigger": {
4
            "url-filter": "save-ping.php"
5
        },
6
        "action": {
7
            "type": "css-display-none",
8
            "selector": ".foo"
9
        }
10
    }
11
]
- LayoutTests/http/tests/contentextensions/hide-on-ping-expected.txt +14 lines
Line 0 LayoutTests/http/tests/contentextensions/hide-on-ping-expected.txt_sec1
1
This test follows a link with a ping attribute where the ping URL matches a 'css-display-none' rule.  
2
3
This text should remain visible.
4
5
--------
6
Frame: 'link_frame'
7
--------
8
Link with ping was clicked.
9
10
--------
11
Frame: 'result_frame'
12
--------
13
Ping received.
14
No cookies in ping.
- LayoutTests/http/tests/contentextensions/hide-on-ping.html +55 lines
Line 0 LayoutTests/http/tests/contentextensions/hide-on-ping.html_sec1
1
<head>
2
<script>
3
if (window.testRunner) {
4
    testRunner.dumpAsText();
5
    testRunner.dumpChildFramesAsText();
6
    testRunner.overridePreference("WebKitHyperlinkAuditingEnabled", 1);
7
    testRunner.waitUntilDone();
8
}
9
10
function loadLinkWithPing() {
11
    var iframe = document.getElementById("link_frame");
12
    var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
13
    iframeDoc.write('' +
14
        '<img src="resources/delete-ping.php?test=contentextensions-hide-on-ping" ' + 
15
            'onerror="parent.clickOnLinkWithPing();">' +
16
        '<a id="a" ' +
17
            'href="resources/check-ping.html" ' + // check-ping.html calls showPingResult()
18
            'ping="resources/save-ping.php?test=contentextensions-hide-on-ping"> ' +
19
            'Link with ping' +
20
        '</a>'
21
        
22
    );
23
}
24
25
function clickOnLinkWithPing() {
26
    var iframe = document.getElementById("link_frame");
27
    var iframeDoc = iframe.contentDocument;
28
    if (window.eventSender) {
29
        var a = iframeDoc.getElementById("a");
30
        var x = iframe.offsetLeft + a.offsetLeft + 2;
31
        var y = iframe.offsetTop + a.offsetTop + 2;
32
        eventSender.mouseMoveTo(x, y);
33
        eventSender.mouseDown();
34
        eventSender.mouseUp();
35
    }
36
}
37
38
function showPingResult() {
39
    var iframe = document.getElementById("result_frame");
40
    iframe.onload = function() {
41
        if (window.testRunner) { testRunner.notifyDone(); }
42
    }
43
    iframe.src = "resources/get-ping-data.php?test=contentextensions-hide-on-ping";
44
}
45
</script>
46
</head>
47
48
<body onload="loadLinkWithPing();">
49
This test follows a link with a ping attribute where the ping URL matches a 'css-display-none' rule.
50
<p class="foo">This text should be hidden once the ping is sent.</p>
51
<p class="bar">This text should remain visible.</p>
52
<iframe id="link_frame"><!-- Will contain link with ping --></iframe>
53
<iframe id="result_frame"><!-- Will contain ping data received by server --></iframe>
54
</body>
55
- LayoutTests/http/tests/contentextensions/hide-on-ping.html.json +11 lines
Line 0 LayoutTests/http/tests/contentextensions/hide-on-ping.html.json_sec1
1
[
2
    {
3
        "trigger": {
4
            "url-filter": "save-ping.php"
5
        },
6
        "action": {
7
            "type": "css-display-none",
8
            "selector": ".foo"
9
        }
10
    }
11
]
- LayoutTests/http/tests/contentextensions/resources/check-ping.html +4 lines
Line 0 LayoutTests/http/tests/contentextensions/resources/check-ping.html_sec1
1
<script>
2
parent.showPingResult()
3
</script>
4
Link with ping was clicked.
- LayoutTests/http/tests/contentextensions/resources/delete-ping.php +5 lines
Line 0 LayoutTests/http/tests/contentextensions/resources/delete-ping.php_sec1
1
<?php
2
require_once 'ping-file-path.php';
3
4
unlink($pingFilePath);
5
?>
- LayoutTests/http/tests/contentextensions/resources/get-ping-data.php +50 lines
Line 0 LayoutTests/http/tests/contentextensions/resources/get-ping-data.php_sec1
1
<?php
2
require_once 'ping-file-path.php';
3
4
$noTimeout = True;
5
$timeoutMsecs = 0;
6
if (isset($_GET['timeout_ms'])) {
7
    $noTimeout = False;
8
    $timeoutMsecs = (int) $_GET['timeout_ms'];
9
}
10
11
$pingFileFound = False;
12
while ($noTimeout || $timeoutMsecs > 0) {
13
    if (file_exists($pingFilePath)) {
14
        $pingFileFound = True;
15
        break;
16
    }
17
    $sleepMsecs = 10;
18
    usleep($sleepMsecs * 1000);
19
    if (!$noTimeout) {
20
        $timeoutMsecs -= $sleepMsecs;
21
    }
22
    // file_exists() caches results, we want to invalidate the cache.
23
    clearstatcache();
24
}
25
26
27
echo "<html><body>\n";
28
29
if ($pingFileFound) {
30
    echo "Ping received.";
31
    $pingFile = fopen($pingFilePath, 'r');
32
    while ($line = fgets($pingFile)) {
33
        echo "<br>";
34
        echo trim($line);
35
    }
36
    fclose($pingFile);
37
    unlink($pingFilePath);
38
} else {
39
    echo "Ping not received - timed out.";
40
}
41
42
if (isset($_GET['end_test'])) {
43
    echo "<script>";
44
    echo "if (window.testRunner)";
45
    echo "    testRunner.notifyDone();";
46
    echo "</script>";
47
}
48
49
echo "</body></html>";
50
?>
- LayoutTests/http/tests/contentextensions/resources/load-in-frame.php +7 lines
Line 0 LayoutTests/http/tests/contentextensions/resources/load-in-frame.php_sec1
1
<?php
2
error_log("rdrct: " . $_GET['to']);
3
if (isset($_GET['to'])) {
4
    echo("<script>location.href=\'" . $_GET['to'] . "\';</script>");
5
}
6
echo "<body>Redirecting</body>";
7
?>
- LayoutTests/http/tests/contentextensions/resources/ping-file-path.php +8 lines
Line 0 LayoutTests/http/tests/contentextensions/resources/ping-file-path.php_sec1
1
<?php
2
require_once '../../resources/portabilityLayer.php';
3
4
if (isset($_GET['test'])) {
5
    $pingFilePath = sys_get_temp_dir() . "/" . str_replace("/", "-", $_GET['test']) . ".ping.txt"; 
6
}
7
8
?>
- LayoutTests/http/tests/contentextensions/resources/redirect.php +6 lines
Line 0 LayoutTests/http/tests/contentextensions/resources/redirect.php_sec1
1
<?php
2
if (isset($_GET['to'])) {
3
    echo("<script>location.href='" . $_GET['to'] . "';</script>");
4
}
5
echo "<body>Redirecting</body>";
6
?>
- LayoutTests/http/tests/contentextensions/resources/save-ping.php +20 lines
Line 0 LayoutTests/http/tests/contentextensions/resources/save-ping.php_sec1
1
<?php
2
require_once 'ping-file-path.php';
3
4
$pingFile = fopen($pingFilePath . ".tmp", 'w');
5
$httpHeaders = $_SERVER;
6
$cookiesFound = false;
7
foreach ($httpHeaders as $name => $value) {
8
    if ($name === "HTTP_COOKIE") {
9
        fwrite($pingFile, "Cookies in ping: $value\n");
10
        $cookiesFound = true;
11
    }
12
}
13
if (!$cookiesFound) {
14
    fwrite($pingFile, "No cookies in ping.\n");
15
}
16
fclose($pingFile);
17
rename($pingFilePath . ".tmp", $pingFilePath);
18
foreach ($_COOKIE as $name => $value)
19
    setcookie($name, "deleted", time() - 60, "/");
20
?>

Return to Bug 149873