Bug 188290 - Add a test for using SafeBrowsing
Summary: Add a test for using SafeBrowsing
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-08-02 17:16 PDT by Alex Christensen
Modified: 2018-08-07 16:19 PDT (History)
5 users (show)

See Also:


Attachments
Patch (18.32 KB, patch)
2018-08-02 17:32 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews200 for win-future (12.90 MB, application/zip)
2018-08-03 06:31 PDT, EWS Watchlist
no flags Details
Patch (18.32 KB, patch)
2018-08-03 10:19 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (17.43 KB, patch)
2018-08-03 11:05 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (10.10 KB, patch)
2018-08-07 15:43 PDT, Alex Christensen
cdumez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>