Changeset 286041 in webkit
- Timestamp:
- Nov 18, 2021 5:35:35 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r286039 r286041 1 2021-11-18 Alex Christensen <achristensen@webkit.org> 2 3 Allow all redirect schemes when compiling a content rule list 4 https://bugs.webkit.org/show_bug.cgi?id=233338 5 6 Reviewed by Tim Hatcher. 7 8 What was I thinking? I made an SPI that gives you a set of allowed redirect schemes 9 from the same source as the JSON which contains those redirect schemes. This allows 10 all redirect schemes. If you want to prevent redirecting to a certain scheme, then 11 don't compile JSON that redirects to that scheme. We may want a helper function that 12 uses the same parser to get the set of schemes being redirected to, but right now that 13 is not necessary because the JSON is being assembled by a program that has the ability 14 to check the schemes. 15 16 * contentextensions/ContentExtensionActions.cpp: 17 (WebCore::ContentExtensions::RedirectAction::parse): 18 (WebCore::ContentExtensions::RedirectAction::URLTransformAction::parse): 19 * contentextensions/ContentExtensionActions.h: 20 * contentextensions/ContentExtensionCompiler.cpp: 21 (WebCore::ContentExtensions::compileRuleList): 22 * contentextensions/ContentExtensionError.cpp: 23 (WebCore::ContentExtensions::contentExtensionErrorCategory): 24 * contentextensions/ContentExtensionError.h: 25 * contentextensions/ContentExtensionParser.cpp: 26 (WebCore::ContentExtensions::loadAction): 27 (WebCore::ContentExtensions::loadRule): 28 (WebCore::ContentExtensions::loadEncodedRules): 29 (WebCore::ContentExtensions::parseRuleList): 30 * contentextensions/ContentExtensionParser.h: 31 1 32 2021-11-18 Chris Dumez <cdumez@apple.com> 2 33 -
trunk/Source/WebCore/contentextensions/ContentExtensionActions.cpp
r285980 r286041 280 280 } 281 281 282 Expected<RedirectAction, std::error_code> RedirectAction::parse(const JSON::Object& redirectObject , const std::optional<HashSet<String>>& allowedRedirectURLSchemes)282 Expected<RedirectAction, std::error_code> RedirectAction::parse(const JSON::Object& redirectObject) 283 283 { 284 284 auto redirect = redirectObject.getObject("redirect"); … … 296 296 297 297 if (auto transform = redirect->getObject("transform")) { 298 auto parsedTransform = URLTransformAction::parse(*transform , allowedRedirectURLSchemes);298 auto parsedTransform = URLTransformAction::parse(*transform); 299 299 if (!parsedTransform) 300 300 return makeUnexpected(parsedTransform.error()); … … 306 306 if (!url.isValid()) 307 307 return makeUnexpected(ContentExtensionError::JSONRedirectURLInvalid); 308 if ( allowedRedirectURLSchemes && !allowedRedirectURLSchemes->contains(url.protocol().toStringWithoutCopying()))309 return makeUnexpected(ContentExtensionError::JSONRedirect URLSchemeNotAllowed);308 if (url.protocolIsJavaScript()) 309 return makeUnexpected(ContentExtensionError::JSONRedirectToJavaScriptURL); 310 310 return RedirectAction { URLAction { WTFMove(urlString) } }; 311 311 } … … 384 384 } 385 385 386 auto RedirectAction::URLTransformAction::parse(const JSON::Object& transform , const std::optional<HashSet<String>>& allowedRedirectURLSchemes) -> Expected<URLTransformAction, std::error_code>386 auto RedirectAction::URLTransformAction::parse(const JSON::Object& transform) -> Expected<URLTransformAction, std::error_code> 387 387 { 388 388 URLTransformAction action; … … 411 411 if (!scheme) 412 412 return makeUnexpected(ContentExtensionError::JSONRedirectURLSchemeInvalid); 413 if ( allowedRedirectURLSchemes && !allowedRedirectURLSchemes->contains(*scheme))414 return makeUnexpected(ContentExtensionError::JSONRedirect URLSchemeNotAllowed);413 if (scheme == "javascript") 414 return makeUnexpected(ContentExtensionError::JSONRedirectToJavaScriptURL); 415 415 action.scheme = WTFMove(*scheme); 416 416 } -
trunk/Source/WebCore/contentextensions/ContentExtensionActions.h
r285980 r286041 208 208 209 209 uint32_t hash() const { return computeHash(fragment.hash(), host.hash(), password.hash(), path.hash(), port, VariantHasher::hash(queryTransform), scheme.hash(), username.hash()); } 210 static Expected<URLTransformAction, std::error_code> parse(const JSON::Object& , const std::optional<HashSet<String>>&);210 static Expected<URLTransformAction, std::error_code> parse(const JSON::Object&); 211 211 URLTransformAction isolatedCopy() const; 212 212 bool operator==(const URLTransformAction&) const; … … 239 239 uint32_t hash() const { return VariantHasher::hash(action); } 240 240 241 static Expected<RedirectAction, std::error_code> parse(const JSON::Object& , const std::optional<HashSet<String>>&);241 static Expected<RedirectAction, std::error_code> parse(const JSON::Object&); 242 242 RedirectAction isolatedCopy() const; 243 243 bool operator==(const RedirectAction&) const; -
trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp
r285980 r286041 276 276 #if ASSERT_ENABLED 277 277 callOnMainThread([ruleJSON = ruleJSON.isolatedCopy(), parsedRuleList = parsedRuleList.isolatedCopy()] { 278 ASSERT(parseRuleList(ruleJSON , std::nullopt).value() == parsedRuleList);278 ASSERT(parseRuleList(ruleJSON).value() == parsedRuleList); 279 279 }); 280 280 #endif -
trunk/Source/WebCore/contentextensions/ContentExtensionError.cpp
r285980 r286041 102 102 case ContentExtensionError::JSONRedirectExtensionPathDoesNotStartWithSlash: 103 103 return "A redirect extension path must start with a slash"; 104 case ContentExtensionError::JSONRedirectURLSchemeNotAllowed:105 return "A redirect url scheme must be in the set of allowed schemes";106 104 case ContentExtensionError::JSONRedirectURLSchemeInvalid: 107 105 return "A redirect url scheme must be a valid scheme"; 108 case ContentExtensionError::JSONRedirect URLSchemesShouldNotIncludeJavascript:109 return " The set of allowed redirect schemes shouldn't includejavascript";106 case ContentExtensionError::JSONRedirectToJavaScriptURL: 107 return "A redirect url can't have a scheme of javascript"; 110 108 case ContentExtensionError::JSONRedirectURLInvalid: 111 109 return "A redirect url must be valid"; -
trunk/Source/WebCore/contentextensions/ContentExtensionError.h
r285980 r286041 62 62 JSONRedirectExtensionPathDoesNotStartWithSlash, 63 63 JSONRedirectURLSchemeInvalid, 64 JSONRedirectURLSchemeNotAllowed, 65 JSONRedirectURLSchemesShouldNotIncludeJavascript, 64 JSONRedirectToJavaScriptURL, 66 65 JSONRedirectURLInvalid, 67 66 JSONRedirectInvalidType, -
trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp
r285980 r286041 180 180 } 181 181 182 static std::optional<Expected<Action, std::error_code>> loadAction(const JSON::Object& ruleObject , const std::optional<HashSet<String>>& allowedRedirectURLSchemes)182 static std::optional<Expected<Action, std::error_code>> loadAction(const JSON::Object& ruleObject) 183 183 { 184 184 auto actionObject = ruleObject.getObject("action"); … … 211 211 } 212 212 if (actionType == "redirect") { 213 auto action = RedirectAction::parse(*actionObject , allowedRedirectURLSchemes);213 auto action = RedirectAction::parse(*actionObject); 214 214 if (!action) 215 215 return makeUnexpected(action.error()); … … 225 225 } 226 226 227 static std::optional<Expected<ContentExtensionRule, std::error_code>> loadRule(const JSON::Object& ruleObject , const std::optional<HashSet<String>>& allowedRedirectURLSchemes)227 static std::optional<Expected<ContentExtensionRule, std::error_code>> loadRule(const JSON::Object& ruleObject) 228 228 { 229 229 auto trigger = loadTrigger(ruleObject); … … 231 231 return makeUnexpected(trigger.error()); 232 232 233 auto action = loadAction(ruleObject , allowedRedirectURLSchemes);233 auto action = loadAction(ruleObject); 234 234 if (!action) 235 235 return std::nullopt; … … 240 240 } 241 241 242 static Expected<Vector<ContentExtensionRule>, std::error_code> loadEncodedRules(const String& ruleJSON, const std::optional<HashSet<String>>& allowedRedirectURLSchemes) 243 { 244 if (allowedRedirectURLSchemes && allowedRedirectURLSchemes->contains("javascript")) 245 return makeUnexpected(ContentExtensionError::JSONRedirectURLSchemesShouldNotIncludeJavascript); 246 242 static Expected<Vector<ContentExtensionRule>, std::error_code> loadEncodedRules(const String& ruleJSON) 243 { 247 244 auto decodedRules = JSON::Value::parseJSON(ruleJSON); 248 245 … … 265 262 return makeUnexpected(ContentExtensionError::JSONInvalidRule); 266 263 267 auto rule = loadRule(*ruleObject , allowedRedirectURLSchemes);264 auto rule = loadRule(*ruleObject); 268 265 if (!rule) 269 266 continue; … … 276 273 } 277 274 278 Expected<Vector<ContentExtensionRule>, std::error_code> parseRuleList(const String& ruleJSON , const std::optional<HashSet<String>>& allowedRedirectURLSchemes)275 Expected<Vector<ContentExtensionRule>, std::error_code> parseRuleList(const String& ruleJSON) 279 276 { 280 277 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING … … 282 279 #endif 283 280 284 auto ruleList = loadEncodedRules(ruleJSON , allowedRedirectURLSchemes);281 auto ruleList = loadEncodedRules(ruleJSON); 285 282 286 283 if (!ruleList.has_value()) -
trunk/Source/WebCore/contentextensions/ContentExtensionParser.h
r285980 r286041 39 39 class ContentExtensionRule; 40 40 41 // An allowedRedirectURLSchemes of std::nullopt indicates that all URL schemes are allowed. 42 // This is used when recompiling source from older versions of WKContentRuleLists on disk, 43 // where we don't have the list of allowed URL schemes but assume that if it compiled 44 // successfully the first time then all the schemes used must have been allowed. 45 // An allowedRedirectURLSchemes of an empty HashSet indicates that no active actions are allowed. 46 WEBCORE_EXPORT Expected<Vector<ContentExtensionRule>, std::error_code> parseRuleList(const String&, const std::optional<HashSet<String>>& allowedRedirectURLSchemes); 41 WEBCORE_EXPORT Expected<Vector<ContentExtensionRule>, std::error_code> parseRuleList(const String&); 47 42 WEBCORE_EXPORT bool isValidCSSSelector(const String&); 48 43 -
trunk/Source/WebKit/ChangeLog
r286037 r286041 1 2021-11-18 Alex Christensen <achristensen@webkit.org> 2 3 Allow all redirect schemes when compiling a content rule list 4 https://bugs.webkit.org/show_bug.cgi?id=233338 5 6 Reviewed by Tim Hatcher. 7 8 * UIProcess/API/APIContentRuleListStore.cpp: 9 (API::ContentRuleListStore::lookupContentRuleList): 10 (API::ContentRuleListStore::compileContentRuleList): 11 * UIProcess/API/APIContentRuleListStore.h: 12 * UIProcess/API/C/WKUserContentExtensionStoreRef.cpp: 13 (WKUserContentExtensionStoreCompile): 14 * UIProcess/API/Cocoa/WKContentRuleListStore.mm: 15 (-[WKContentRuleListStore compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:]): 16 (-[WKContentRuleListStore _compileContentRuleListForIdentifier:encodedContentRuleList:allowedRedirectSchemes:completionHandler:]): Deleted. 17 * UIProcess/API/Cocoa/WKContentRuleListStorePrivate.h: 18 * UIProcess/API/glib/WebKitUserContentFilterStore.cpp: 19 (webkitUserContentFilterStoreSaveBytes): 20 1 21 2021-11-18 Per Arne Vollan <pvollan@apple.com> 2 22 -
trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp
r285980 r286041 492 492 if (auto sourceFromOldVersion = getContentRuleListSourceFromMappedFile(*contentRuleList); !sourceFromOldVersion.isEmpty()) { 493 493 RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), sourceFromOldVersion = sourceFromOldVersion.isolatedCopy(), identifier = identifier.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable { 494 protectedThis->compileContentRuleList(identifier, WTFMove(sourceFromOldVersion), std::nullopt,WTFMove(completionHandler));494 protectedThis->compileContentRuleList(identifier, WTFMove(sourceFromOldVersion), WTFMove(completionHandler)); 495 495 }); 496 496 return; … … 531 531 } 532 532 533 void ContentRuleListStore::compileContentRuleList(const WTF::String& identifier, WTF::String&& json, std::optional<HashSet<WTF::String>>&& allowedRedirectSchemes,CompletionHandler<void(RefPtr<API::ContentRuleList>, std::error_code)> completionHandler)533 void ContentRuleListStore::compileContentRuleList(const WTF::String& identifier, WTF::String&& json, CompletionHandler<void(RefPtr<API::ContentRuleList>, std::error_code)> completionHandler) 534 534 { 535 535 ASSERT(RunLoop::isMain()); … … 537 537 WebCore::QualifiedName::init(); 538 538 539 auto parsedRules = WebCore::ContentExtensions::parseRuleList(json , WTFMove(allowedRedirectSchemes));539 auto parsedRules = WebCore::ContentExtensions::parseRuleList(json); 540 540 if (!parsedRules.has_value()) 541 541 return completionHandler(nullptr, parsedRules.error()); -
trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.h
r285980 r286041 67 67 virtual ~ContentRuleListStore(); 68 68 69 void compileContentRuleList(const WTF::String& identifier, WTF::String&& json, std::optional<HashSet<WTF::String>>&& allowedRedirectSchemes,CompletionHandler<void(RefPtr<API::ContentRuleList>, std::error_code)>);69 void compileContentRuleList(const WTF::String& identifier, WTF::String&& json, CompletionHandler<void(RefPtr<API::ContentRuleList>, std::error_code)>); 70 70 void lookupContentRuleList(const WTF::String& identifier, CompletionHandler<void(RefPtr<API::ContentRuleList>, std::error_code)>); 71 71 void removeContentRuleList(const WTF::String& identifier, CompletionHandler<void(std::error_code)>); -
trunk/Source/WebKit/UIProcess/API/C/WKUserContentExtensionStoreRef.cpp
r285980 r286041 77 77 { 78 78 #if ENABLE(CONTENT_EXTENSIONS) 79 toImpl(store)->compileContentRuleList(toWTFString(identifier), toWTFString(jsonSource), { HashSet<String>() },[context, callback](RefPtr<API::ContentRuleList> contentRuleList, std::error_code error) {79 toImpl(store)->compileContentRuleList(toWTFString(identifier), toWTFString(jsonSource), [context, callback](RefPtr<API::ContentRuleList> contentRuleList, std::error_code error) { 80 80 callback(error ? nullptr : toAPI(contentRuleList.leakRef()), toResult(error), context); 81 81 }); -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListStore.mm
r285980 r286041 88 88 - (void)compileContentRuleListForIdentifier:(NSString *)identifier encodedContentRuleList:(NSString *)encodedContentRuleList completionHandler:(void (^)(WKContentRuleList *, NSError *))completionHandler 89 89 { 90 [self _compileContentRuleListForIdentifier:identifier encodedContentRuleList:encodedContentRuleList allowedRedirectSchemes:nil completionHandler:completionHandler]; 90 #if ENABLE(CONTENT_EXTENSIONS) 91 _contentRuleListStore->compileContentRuleList(identifier, encodedContentRuleList, [completionHandler = makeBlockPtr(completionHandler)](RefPtr<API::ContentRuleList> contentRuleList, std::error_code error) { 92 if (error) { 93 auto userInfo = @{ NSHelpAnchorErrorKey: [NSString stringWithFormat:@"Rule list compilation failed: %s", error.message().c_str()] }; 94 95 // error.value() could have a specific compiler error that is not equal to WKErrorContentRuleListStoreCompileFailed. 96 // We want to use error.message, but here we want to only pass on CompileFailed with userInfo from the std::error_code. 97 return completionHandler(nil, [NSError errorWithDomain:WKErrorDomain code:WKErrorContentRuleListStoreCompileFailed userInfo:userInfo]); 98 } 99 completionHandler(wrapper(*contentRuleList), nil); 100 }); 101 #endif 91 102 } 92 103 … … 172 183 } 173 184 174 - (void)_compileContentRuleListForIdentifier:(NSString *)identifier encodedContentRuleList:(NSString *)encodedContentRuleList allowedRedirectSchemes:(NSSet<NSString *> *)schemes completionHandler:(void (^)(WKContentRuleList *, NSError *))completionHandler175 {176 #if ENABLE(CONTENT_EXTENSIONS)177 HashSet<String> allowedRedirectSchemes;178 for (NSString *scheme in schemes)179 allowedRedirectSchemes.add(scheme);180 _contentRuleListStore->compileContentRuleList(identifier, encodedContentRuleList, WTFMove(allowedRedirectSchemes), [completionHandler = makeBlockPtr(completionHandler)](RefPtr<API::ContentRuleList> contentRuleList, std::error_code error) {181 if (error) {182 auto userInfo = @{NSHelpAnchorErrorKey: [NSString stringWithFormat:@"Rule list compilation failed: %s", error.message().c_str()]};183 184 // error.value() could have a specific compiler error that is not equal to WKErrorContentRuleListStoreCompileFailed.185 // We want to use error.message, but here we want to only pass on CompileFailed with userInfo from the std::error_code.186 return completionHandler(nil, [NSError errorWithDomain:WKErrorDomain code:WKErrorContentRuleListStoreCompileFailed userInfo:userInfo]);187 }188 completionHandler(wrapper(*contentRuleList), nil);189 });190 #endif191 }192 193 185 + (instancetype)defaultStoreWithLegacyFilename 194 186 { -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListStorePrivate.h
r285980 r286041 33 33 - (void)_getContentRuleListSourceForIdentifier:(NSString *)identifier completionHandler:(void (^)(NSString *))completionHandler; 34 34 35 - (void)_compileContentRuleListForIdentifier:(NSString *)identifier encodedContentRuleList:(NSString *)encodedContentRuleList allowedRedirectSchemes:(NSSet<NSString *> *)schemes completionHandler:(void (^)(WKContentRuleList *, NSError *))completionHandler;36 37 35 // FIXME: Remove _WKUserContentExtensionStore. 38 36 + (instancetype)defaultStoreWithLegacyFilename; -
trunk/Source/WebKit/UIProcess/API/glib/WebKitUserContentFilterStore.cpp
r285980 r286041 188 188 189 189 auto* store = WEBKIT_USER_CONTENT_FILTER_STORE(g_task_get_source_object(task.get())); 190 store->priv->store->compileContentRuleList(identifier, String::fromUTF8(sourceData, sourceSize), { HashSet<String>() },[task = WTFMove(task)](RefPtr<API::ContentRuleList> contentRuleList, std::error_code error) {190 store->priv->store->compileContentRuleList(identifier, String::fromUTF8(sourceData, sourceSize), [task = WTFMove(task)](RefPtr<API::ContentRuleList> contentRuleList, std::error_code error) { 191 191 if (g_task_return_error_if_cancelled(task.get())) 192 192 return; -
trunk/Tools/ChangeLog
r286040 r286041 1 2021-11-18 Alex Christensen <achristensen@webkit.org> 2 3 Allow all redirect schemes when compiling a content rule list 4 https://bugs.webkit.org/show_bug.cgi?id=233338 5 6 Reviewed by Tim Hatcher. 7 8 * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: 9 (TestWebKitAPI::InMemoryCompiledContentExtension::create): 10 (TestWebKitAPI::checkCompilerError): 11 (TestWebKitAPI::TEST_F): 12 * TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm: 13 (compileContentRuleList): 14 1 15 2021-11-18 Robert Jenner <Jenner@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp
r285980 r286041 132 132 CompiledContentExtensionData extensionData; 133 133 InMemoryContentExtensionCompilationClient client(extensionData); 134 auto parsedRules = ContentExtensions::parseRuleList(filter , std::nullopt);134 auto parsedRules = ContentExtensions::parseRuleList(filter); 135 135 auto compilerError = ContentExtensions::compileRuleList(client, WTFMove(filter), WTFMove(parsedRules.value())); 136 136 … … 1363 1363 } 1364 1364 1365 void checkCompilerError(const char* json, std::error_code expectedError , const std::optional<HashSet<String>>& allowedRedirectURLSchemes = std::nullopt)1365 void checkCompilerError(const char* json, std::error_code expectedError) 1366 1366 { 1367 1367 CompiledContentExtensionData extensionData; 1368 1368 InMemoryContentExtensionCompilationClient client(extensionData); 1369 auto parsedRules = ContentExtensions::parseRuleList(json , allowedRedirectURLSchemes);1369 auto parsedRules = ContentExtensions::parseRuleList(json); 1370 1370 std::error_code compilerError; 1371 1371 if (parsedRules.has_value()) … … 1533 1533 checkCompilerError("[{\"action\":{\"type\":\"css-display-none\"},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", 1534 1534 ContentExtensionError::JSONInvalidCSSDisplayNoneActionType); 1535 checkCompilerError("", ContentExtensionError::JSONRedirectURLSchemesShouldNotIncludeJavascript, { { "javascript" } });1536 1535 1537 1536 checkCompilerError("[{\"action\":{\"type\":\"ignore-previous-rules\"},\"trigger\":{\"url-filter\":\"webkit.org\"}}," … … 1562 1561 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"transform\":{\"query-transform\":{\"add-or-replace-parameters\":[{\"key\":5}]}}}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONAddOrReplaceParametersKeyValueMissingKeyString); 1563 1562 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"transform\":{\"query-transform\":{\"add-or-replace-parameters\":[{\"key\":\"k\",\"value\":5}]}}}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONAddOrReplaceParametersKeyValueMissingValueString); 1564 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"url\":\"about:blank\"}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONRedirectURLSchemeNotAllowed, { { "not-about" } }); 1565 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"url\":\"about:blank\"}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", { }, { { "about" } }); 1566 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"url\":\"https://127..1/\"}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONRedirectURLInvalid, { { "https" } }); 1567 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"url\":\"about:blank\"}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", { }, { { "about" } }); 1563 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"url\":\"https://127..1/\"}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONRedirectURLInvalid); 1564 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"url\":\"JaVaScRiPt:dostuff\"}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONRedirectToJavaScriptURL); 1568 1565 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"transform\":{\"port\":\"not a number\"}}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONRedirectInvalidPort); 1569 1566 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"transform\":{\"port\":\"65536\"}}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONRedirectInvalidPort); … … 1573 1570 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"transform\":{\"port\":\"\"}}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", { }); 1574 1571 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"extension-path\":\"/does/start/with/slash/\"}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", { }); 1575 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"transform\":{\"scheme\":\"about\"}}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONRedirectURLSchemeNotAllowed, { { "not-about" } });1576 1572 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"transform\":{\"scheme\":\"!@#$%\"}}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONRedirectURLSchemeInvalid); 1577 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"transform\":{\"scheme\":\"About\"}}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", { }, { { "about" } }); 1573 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"transform\":{\"scheme\":\"JaVaScRiPt\"}}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONRedirectToJavaScriptURL); 1574 checkCompilerError("[{\"action\":{\"type\":\"redirect\",\"redirect\":{\"transform\":{\"scheme\":\"About\"}}},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", { }); 1578 1575 checkCompilerError("[{\"action\":{\"type\":\"modify-headers\",\"request-headers\":5},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONModifyHeadersNotArray); 1579 1576 checkCompilerError("[{\"action\":{\"type\":\"modify-headers\",\"request-headers\":[5]},\"trigger\":{\"url-filter\":\"webkit.org\"}}]", ContentExtensionError::JSONModifyHeadersInfoNotADictionary); -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm
r285980 r286041 485 485 486 486 __block RetainPtr<WKContentRuleList> list; 487 [[WKContentRuleListStore defaultStore] _compileContentRuleListForIdentifier:@"testidentifier" encodedContentRuleList:[NSString stringWithFormat:@"%s", json] allowedRedirectSchemes:[NSSet setWithObjects:@"testscheme", @"othertestscheme", nil] completionHandler:^(WKContentRuleList *filter, NSError *error) {487 [[WKContentRuleListStore defaultStore] compileContentRuleListForIdentifier:@"testidentifier" encodedContentRuleList:[NSString stringWithFormat:@"%s", json] completionHandler:^(WKContentRuleList *filter, NSError *error) { 488 488 EXPECT_NULL(error); 489 489 list = filter;
Note: See TracChangeset
for help on using the changeset viewer.