Bug 188290

Summary: Add a test for using SafeBrowsing
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, ews-watchlist, mitz, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews200 for win-future
none
Patch
none
Patch
none
Patch cdumez: review+

Description Alex Christensen 2018-08-02 17:16:59 PDT
Add SPI to test safe browsing
Comment 1 Alex Christensen 2018-08-02 17:32:14 PDT
Created attachment 346437 [details]
Patch
Comment 2 EWS Watchlist 2018-08-03 06:31:09 PDT
Comment on attachment 346437 [details]
Patch

Attachment 346437 [details] did not pass win-ews (win):
Output: https://webkit-queues.webkit.org/results/8749373

New failing tests:
http/tests/security/video-poster-cross-origin-crash2.html
Comment 3 EWS Watchlist 2018-08-03 06:31:20 PDT
Created attachment 346476 [details]
Archive of layout-test-results from ews200 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews200  Port: win-future  Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Comment 4 Alex Christensen 2018-08-03 10:19:24 PDT
Created attachment 346501 [details]
Patch
Comment 5 Alex Christensen 2018-08-03 11:05:58 PDT
Created attachment 346506 [details]
Patch
Comment 6 mitz 2018-08-03 15:55:24 PDT
Comment on attachment 346506 [details]
Patch

Have you tried testing by using the Objective-C runtime to replace [SSBLookupContext sharedLookupContext] with an object of your choosing at runtime? Seems less invasive and doesn’t require any changes to production code.
Comment 7 Tim Horton 2018-08-03 15:55:42 PDT
Comment on attachment 346506 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=346506&action=review

> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:5875
> +        handler.get()(url, BlockPtr<void(BOOL)>::fromCallable([completionHandler = WTFMove(completionHandler)] (BOOL phishing) mutable {

should this be "isUnsafe" or something?

> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:5876
> +            completionHandler({{ "MockSafeBrowsingProvider"_s, !!phishing, false, false, false }});

why the !!
Comment 8 Alex Christensen 2018-08-03 15:57:55 PDT
(In reply to mitz from comment #6)
> Comment on attachment 346506 [details]
> Patch
> 
> Have you tried testing by using the Objective-C runtime to replace
> [SSBLookupContext sharedLookupContext] with an object of your choosing at
> runtime? Seems less invasive and doesn’t require any changes to production
> code.
That's a great idea.  Then I wouldn't need any of this!

(In reply to Tim Horton from comment #7)
> Comment on attachment 346506 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=346506&action=review
> 
> > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:5875
> > +        handler.get()(url, BlockPtr<void(BOOL)>::fromCallable([completionHandler = WTFMove(completionHandler)] (BOOL phishing) mutable {
> 
> should this be "isUnsafe" or something?
isPhishing

> > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:5876
> > +            completionHandler({{ "MockSafeBrowsingProvider"_s, !!phishing, false, false, false }});
> 
> why the !!
This is needed to convert BOOL to bool.
Comment 9 Alex Christensen 2018-08-07 15:43:19 PDT
Created attachment 346739 [details]
Patch
Comment 10 Chris Dumez 2018-08-07 16:11:51 PDT
Comment on attachment 346739 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=346739&action=review

r=me with comment.

> Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:136
> +    static NeverDestroyed<RetainPtr<TestLookupContext>> context;

Why NeverDestroyed with a RetainPtr? Why not the following?
static TestLookupContext *context = [[TestLookupContext alloc] init];
return context;
Comment 11 Alex Christensen 2018-08-07 16:18:25 PDT
http://trac.webkit.org/r234676
Comment 12 Radar WebKit Bug Importer 2018-08-07 16:19:40 PDT
<rdar://problem/43025805>