haikuwebkit/LayoutTests/contentfiltering/block-after-response.html

9 lines
263 B
HTML
Raw Permalink Normal View History

[Content Filtering] Add tests https://bugs.webkit.org/show_bug.cgi?id=142475 Reviewed by Andreas Kling. Source/WebCore: Added a mock content filter that can be configured by window.internals. A test can control whether the filter is enabled, what to display when a page is blocked, at what point the allow/block decision is made, and what decision to make. Added tests to cover allowing and blocking content at each decision point. Tests: contentfiltering/allow-after-add-data.html contentfiltering/allow-after-finished-adding-data.html contentfiltering/allow-after-response.html contentfiltering/block-after-add-data.html contentfiltering/block-after-finished-adding-data.html contentfiltering/block-after-response.html * DerivedSources.make: Added MockContentFilterSettings.idl. * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSMockContentFilterSettingsCustom.cpp: Added. (WebCore::JSMockContentFilterSettings::decisionPoint): Returned the decision point's JSValue. (WebCore::JSMockContentFilterSettings::setDecisionPoint): Set the decision point; threw an exception for invalid values. (WebCore::JSMockContentFilterSettings::decision): Returned the decision's JSValue. (WebCore::JSMockContentFilterSettings::setDecision): Set the decision; threw an exception for invalid values. * platform/ContentFilter.cpp: (WebCore::ContentFilter::types): Renamed from contentFilterTypes. (WebCore::ContentFilter::createIfNeeded): (WebCore::contentFilterType): Deleted. (WebCore::contentFilterTypes): Deleted. * platform/ContentFilter.h: (WebCore::ContentFilter::addType): Used to register a new content filter type. (WebCore::ContentFilter::type): Renamed from contentFilterType. * platform/cocoa/NetworkExtensionContentFilter.h: Moved definition of HAVE_NE_FILTER_SOURCE to here. * testing/Internals.cpp: (WebCore::Internals::resetToConsistentState): Called MockContentFilterSettings::reset(). (WebCore::Internals::Internals): Called MockContentFilter::ensureInstalled(). (WebCore::Internals::mockContentFilterSettings): Returned a reference to MockContentFilterSettings::singleton(). * testing/Internals.h: * testing/Internals.idl: Added attribute mockContentFilterSettings. * testing/MockContentFilter.cpp: Added. (WebCore::MockContentFilter::ensureInstalled): Called MockContentFilter::addType(). (WebCore::MockContentFilter::canHandleResponse): Returned whether MockContentFilterSettings is enabled. (WebCore::MockContentFilter::create): Returned a new MockContentFilter. (WebCore::MockContentFilter::MockContentFilter): Called maybeDetermineStatus(). (WebCore::MockContentFilter::addData): Copied data into m_replacementData and called maybeDetermineStatus(). (WebCore::MockContentFilter::finishedAddingData): Called maybeDetermineStatus(). (WebCore::MockContentFilter::needsMoreData): Returned whether m_status equals NeedsMoreData. (WebCore::MockContentFilter::didBlockData): Returned whether m_status equals Blocked. (WebCore::MockContentFilter::getReplacementData): Returned a pointer to the start of m_replacementData. (WebCore::MockContentFilter::unblockHandler): Returned an empty ContentFilterUnblockHandler. (WebCore::MockContentFilter::maybeDetermineStatus): If m_status is NeedsMoreData and the current decision point equals MockContentFilterSettings's decision point, set m_status according to MockContentFilterSettings's decision. If m_status becomes Blocked, clear the original page data from m_replacementData and copy MockContentFilterSettings's blocked string instead. * testing/MockContentFilter.h: Copied from Source/WebCore/platform/cocoa/NetworkExtensionContentFilter.h. * testing/MockContentFilterSettings.cpp: Copied from Source/WebCore/platform/ContentFilter.h. (WebCore::MockContentFilterSettings::singleton): (WebCore::MockContentFilterSettings::reset): Reset settings to their initial values. (WebCore::MockContentFilterSettings::MockContentFilterSettings): * testing/MockContentFilterSettings.h: Copied from Source/WebCore/platform/cocoa/NetworkExtensionContentFilter.h. (WebCore::MockContentFilterSettings::ref): Added an empty implementation to make the bindings think this is RefCounted. (WebCore::MockContentFilterSettings::deref): Ditto. (WebCore::MockContentFilterSettings::enabled): (WebCore::MockContentFilterSettings::setEnabled): (WebCore::MockContentFilterSettings::blockedString): (WebCore::MockContentFilterSettings::setBlockedString): (WebCore::MockContentFilterSettings::decisionPoint): (WebCore::MockContentFilterSettings::setDecisionPoint): (WebCore::MockContentFilterSettings::decision): (WebCore::MockContentFilterSettings::setDecision): * testing/MockContentFilterSettings.idl: Copied from Source/WebCore/platform/ContentFilter.h. LayoutTests: * contentfiltering/allow-after-add-data-expected.html: Added. * contentfiltering/allow-after-add-data.html: Added. * contentfiltering/allow-after-finished-adding-data-expected.html: Added. * contentfiltering/allow-after-finished-adding-data.html: Added. * contentfiltering/allow-after-response-expected.html: Added. * contentfiltering/allow-after-response.html: Added. * contentfiltering/block-after-add-data-expected.html: Added. * contentfiltering/block-after-add-data.html: Added. * contentfiltering/block-after-finished-adding-data-expected.html: Added. * contentfiltering/block-after-finished-adding-data.html: Added. * contentfiltering/block-after-response-expected.html: Added. * contentfiltering/block-after-response.html: Added. Canonical link: https://commits.webkit.org/160544@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181291 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-09 23:39:05 +00:00
<!DOCTYPE html>
<script src="resources/contentfiltering.js"></script>
[Content Filtering] Add tests https://bugs.webkit.org/show_bug.cgi?id=142475 Reviewed by Andreas Kling. Source/WebCore: Added a mock content filter that can be configured by window.internals. A test can control whether the filter is enabled, what to display when a page is blocked, at what point the allow/block decision is made, and what decision to make. Added tests to cover allowing and blocking content at each decision point. Tests: contentfiltering/allow-after-add-data.html contentfiltering/allow-after-finished-adding-data.html contentfiltering/allow-after-response.html contentfiltering/block-after-add-data.html contentfiltering/block-after-finished-adding-data.html contentfiltering/block-after-response.html * DerivedSources.make: Added MockContentFilterSettings.idl. * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSMockContentFilterSettingsCustom.cpp: Added. (WebCore::JSMockContentFilterSettings::decisionPoint): Returned the decision point's JSValue. (WebCore::JSMockContentFilterSettings::setDecisionPoint): Set the decision point; threw an exception for invalid values. (WebCore::JSMockContentFilterSettings::decision): Returned the decision's JSValue. (WebCore::JSMockContentFilterSettings::setDecision): Set the decision; threw an exception for invalid values. * platform/ContentFilter.cpp: (WebCore::ContentFilter::types): Renamed from contentFilterTypes. (WebCore::ContentFilter::createIfNeeded): (WebCore::contentFilterType): Deleted. (WebCore::contentFilterTypes): Deleted. * platform/ContentFilter.h: (WebCore::ContentFilter::addType): Used to register a new content filter type. (WebCore::ContentFilter::type): Renamed from contentFilterType. * platform/cocoa/NetworkExtensionContentFilter.h: Moved definition of HAVE_NE_FILTER_SOURCE to here. * testing/Internals.cpp: (WebCore::Internals::resetToConsistentState): Called MockContentFilterSettings::reset(). (WebCore::Internals::Internals): Called MockContentFilter::ensureInstalled(). (WebCore::Internals::mockContentFilterSettings): Returned a reference to MockContentFilterSettings::singleton(). * testing/Internals.h: * testing/Internals.idl: Added attribute mockContentFilterSettings. * testing/MockContentFilter.cpp: Added. (WebCore::MockContentFilter::ensureInstalled): Called MockContentFilter::addType(). (WebCore::MockContentFilter::canHandleResponse): Returned whether MockContentFilterSettings is enabled. (WebCore::MockContentFilter::create): Returned a new MockContentFilter. (WebCore::MockContentFilter::MockContentFilter): Called maybeDetermineStatus(). (WebCore::MockContentFilter::addData): Copied data into m_replacementData and called maybeDetermineStatus(). (WebCore::MockContentFilter::finishedAddingData): Called maybeDetermineStatus(). (WebCore::MockContentFilter::needsMoreData): Returned whether m_status equals NeedsMoreData. (WebCore::MockContentFilter::didBlockData): Returned whether m_status equals Blocked. (WebCore::MockContentFilter::getReplacementData): Returned a pointer to the start of m_replacementData. (WebCore::MockContentFilter::unblockHandler): Returned an empty ContentFilterUnblockHandler. (WebCore::MockContentFilter::maybeDetermineStatus): If m_status is NeedsMoreData and the current decision point equals MockContentFilterSettings's decision point, set m_status according to MockContentFilterSettings's decision. If m_status becomes Blocked, clear the original page data from m_replacementData and copy MockContentFilterSettings's blocked string instead. * testing/MockContentFilter.h: Copied from Source/WebCore/platform/cocoa/NetworkExtensionContentFilter.h. * testing/MockContentFilterSettings.cpp: Copied from Source/WebCore/platform/ContentFilter.h. (WebCore::MockContentFilterSettings::singleton): (WebCore::MockContentFilterSettings::reset): Reset settings to their initial values. (WebCore::MockContentFilterSettings::MockContentFilterSettings): * testing/MockContentFilterSettings.h: Copied from Source/WebCore/platform/cocoa/NetworkExtensionContentFilter.h. (WebCore::MockContentFilterSettings::ref): Added an empty implementation to make the bindings think this is RefCounted. (WebCore::MockContentFilterSettings::deref): Ditto. (WebCore::MockContentFilterSettings::enabled): (WebCore::MockContentFilterSettings::setEnabled): (WebCore::MockContentFilterSettings::blockedString): (WebCore::MockContentFilterSettings::setBlockedString): (WebCore::MockContentFilterSettings::decisionPoint): (WebCore::MockContentFilterSettings::setDecisionPoint): (WebCore::MockContentFilterSettings::decision): (WebCore::MockContentFilterSettings::setDecision): * testing/MockContentFilterSettings.idl: Copied from Source/WebCore/platform/ContentFilter.h. LayoutTests: * contentfiltering/allow-after-add-data-expected.html: Added. * contentfiltering/allow-after-add-data.html: Added. * contentfiltering/allow-after-finished-adding-data-expected.html: Added. * contentfiltering/allow-after-finished-adding-data.html: Added. * contentfiltering/allow-after-response-expected.html: Added. * contentfiltering/allow-after-response.html: Added. * contentfiltering/block-after-add-data-expected.html: Added. * contentfiltering/block-after-add-data.html: Added. * contentfiltering/block-after-finished-adding-data-expected.html: Added. * contentfiltering/block-after-finished-adding-data.html: Added. * contentfiltering/block-after-response-expected.html: Added. * contentfiltering/block-after-response.html: Added. Canonical link: https://commits.webkit.org/160544@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181291 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-09 23:39:05 +00:00
<script>
if (window.internals) {
var settings = window.internals.mockContentFilterSettings;
[WebIDL] Remove custom bindings for MockContentFilterSettings https://bugs.webkit.org/show_bug.cgi?id=174606 Patch by Sam Weinig <sam@webkit.org> on 2017-07-18 Reviewed by Andy Estes. Source/WebCore: * PlatformMac.cmake: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSMockContentFilterSettingsCustom.cpp: Removed. Remove JSMockContentFilterSettingsCustom. * testing/MockContentFilterSettings.h: * testing/MockContentFilterSettings.idl: Switch from constants to IDL enums to make the bindings and tests simpler. LayoutTests: * contentfiltering/allow-after-add-data.html: * contentfiltering/allow-after-finished-adding-data.html: * contentfiltering/allow-after-response.html: * contentfiltering/allow-after-will-send-request.html: * contentfiltering/allow-empty-document.html: * contentfiltering/allow-media-document.html: * contentfiltering/allow-never.html: * contentfiltering/block-after-add-data-then-allow-unblock.html: * contentfiltering/block-after-add-data-then-deny-unblock.html: * contentfiltering/block-after-add-data.html: * contentfiltering/block-after-finished-adding-data-then-allow-unblock.html: * contentfiltering/block-after-finished-adding-data-then-deny-unblock.html: * contentfiltering/block-after-finished-adding-data.html: * contentfiltering/block-after-response-then-allow-unblock.html: * contentfiltering/block-after-response-then-deny-unblock.html: * contentfiltering/block-after-response.html: * contentfiltering/block-after-will-send-request-then-allow-unblock.html: * contentfiltering/block-after-will-send-request-then-deny-unblock.html: * contentfiltering/block-after-will-send-request.html: * contentfiltering/block-never.html: * contentfiltering/modify-request-url.html: * contentfiltering/resources/contentfiltering.js: * http/tests/contentfiltering/allow-after-redirect.html: * http/tests/contentfiltering/block-after-redirect.html: * http/tests/contentfiltering/load-substitute-data-from-appcache.html: * http/tests/contentfiltering/modify-redirect-request-url.html: Update tests to use new MockContentFilterSettings enums rather than constants. Canonical link: https://commits.webkit.org/191434@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219623 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-18 20:14:31 +00:00
testContentFiltering(/* decisionPoint */"afterResponse", /* decision */"block");
}
[Content Filtering] Add tests https://bugs.webkit.org/show_bug.cgi?id=142475 Reviewed by Andreas Kling. Source/WebCore: Added a mock content filter that can be configured by window.internals. A test can control whether the filter is enabled, what to display when a page is blocked, at what point the allow/block decision is made, and what decision to make. Added tests to cover allowing and blocking content at each decision point. Tests: contentfiltering/allow-after-add-data.html contentfiltering/allow-after-finished-adding-data.html contentfiltering/allow-after-response.html contentfiltering/block-after-add-data.html contentfiltering/block-after-finished-adding-data.html contentfiltering/block-after-response.html * DerivedSources.make: Added MockContentFilterSettings.idl. * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSMockContentFilterSettingsCustom.cpp: Added. (WebCore::JSMockContentFilterSettings::decisionPoint): Returned the decision point's JSValue. (WebCore::JSMockContentFilterSettings::setDecisionPoint): Set the decision point; threw an exception for invalid values. (WebCore::JSMockContentFilterSettings::decision): Returned the decision's JSValue. (WebCore::JSMockContentFilterSettings::setDecision): Set the decision; threw an exception for invalid values. * platform/ContentFilter.cpp: (WebCore::ContentFilter::types): Renamed from contentFilterTypes. (WebCore::ContentFilter::createIfNeeded): (WebCore::contentFilterType): Deleted. (WebCore::contentFilterTypes): Deleted. * platform/ContentFilter.h: (WebCore::ContentFilter::addType): Used to register a new content filter type. (WebCore::ContentFilter::type): Renamed from contentFilterType. * platform/cocoa/NetworkExtensionContentFilter.h: Moved definition of HAVE_NE_FILTER_SOURCE to here. * testing/Internals.cpp: (WebCore::Internals::resetToConsistentState): Called MockContentFilterSettings::reset(). (WebCore::Internals::Internals): Called MockContentFilter::ensureInstalled(). (WebCore::Internals::mockContentFilterSettings): Returned a reference to MockContentFilterSettings::singleton(). * testing/Internals.h: * testing/Internals.idl: Added attribute mockContentFilterSettings. * testing/MockContentFilter.cpp: Added. (WebCore::MockContentFilter::ensureInstalled): Called MockContentFilter::addType(). (WebCore::MockContentFilter::canHandleResponse): Returned whether MockContentFilterSettings is enabled. (WebCore::MockContentFilter::create): Returned a new MockContentFilter. (WebCore::MockContentFilter::MockContentFilter): Called maybeDetermineStatus(). (WebCore::MockContentFilter::addData): Copied data into m_replacementData and called maybeDetermineStatus(). (WebCore::MockContentFilter::finishedAddingData): Called maybeDetermineStatus(). (WebCore::MockContentFilter::needsMoreData): Returned whether m_status equals NeedsMoreData. (WebCore::MockContentFilter::didBlockData): Returned whether m_status equals Blocked. (WebCore::MockContentFilter::getReplacementData): Returned a pointer to the start of m_replacementData. (WebCore::MockContentFilter::unblockHandler): Returned an empty ContentFilterUnblockHandler. (WebCore::MockContentFilter::maybeDetermineStatus): If m_status is NeedsMoreData and the current decision point equals MockContentFilterSettings's decision point, set m_status according to MockContentFilterSettings's decision. If m_status becomes Blocked, clear the original page data from m_replacementData and copy MockContentFilterSettings's blocked string instead. * testing/MockContentFilter.h: Copied from Source/WebCore/platform/cocoa/NetworkExtensionContentFilter.h. * testing/MockContentFilterSettings.cpp: Copied from Source/WebCore/platform/ContentFilter.h. (WebCore::MockContentFilterSettings::singleton): (WebCore::MockContentFilterSettings::reset): Reset settings to their initial values. (WebCore::MockContentFilterSettings::MockContentFilterSettings): * testing/MockContentFilterSettings.h: Copied from Source/WebCore/platform/cocoa/NetworkExtensionContentFilter.h. (WebCore::MockContentFilterSettings::ref): Added an empty implementation to make the bindings think this is RefCounted. (WebCore::MockContentFilterSettings::deref): Ditto. (WebCore::MockContentFilterSettings::enabled): (WebCore::MockContentFilterSettings::setEnabled): (WebCore::MockContentFilterSettings::blockedString): (WebCore::MockContentFilterSettings::setBlockedString): (WebCore::MockContentFilterSettings::decisionPoint): (WebCore::MockContentFilterSettings::setDecisionPoint): (WebCore::MockContentFilterSettings::decision): (WebCore::MockContentFilterSettings::setDecision): * testing/MockContentFilterSettings.idl: Copied from Source/WebCore/platform/ContentFilter.h. LayoutTests: * contentfiltering/allow-after-add-data-expected.html: Added. * contentfiltering/allow-after-add-data.html: Added. * contentfiltering/allow-after-finished-adding-data-expected.html: Added. * contentfiltering/allow-after-finished-adding-data.html: Added. * contentfiltering/allow-after-response-expected.html: Added. * contentfiltering/allow-after-response.html: Added. * contentfiltering/block-after-add-data-expected.html: Added. * contentfiltering/block-after-add-data.html: Added. * contentfiltering/block-after-finished-adding-data-expected.html: Added. * contentfiltering/block-after-finished-adding-data.html: Added. * contentfiltering/block-after-response-expected.html: Added. * contentfiltering/block-after-response.html: Added. Canonical link: https://commits.webkit.org/160544@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181291 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-09 23:39:05 +00:00
</script>