For service worker, add browser tests to check that the top_frame_origin is null
and the request_initiator is the script origin.

Also fixed 2 issues:
- For the main resource request (serviceWorker.register(...)), it goes through
FrameFetchContext::PrepareRequest() that will always set the top_frame_origin
regardless whether it's from service worker. Adding a check for service worker
seems to fix it.
- The static function GetNetworkFactoryCallbackForTest() in
embedded_worker_instance.cc returns an Optional of Callback, but the caller only
checks the nullity of the Optional but not of the Callback. This sometimes is
causing a crash in the test. Removing the Optional seems to fix it.

Bug: 918868
Change-Id: I2a5b83d8b13b2d52310614dfb5a6dfa4d1cd620a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1553948
Commit-Queue: Yao Xiao <yaoxia@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Shivani Sharma <shivanisha@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652483}
9 files changed