ServiceWorker: Wait for registration promise to resolve before changing states.

V8 Promise resolving is done as an async task. So resolving the
ServiceWorker registration promise followed by installing and activating
the worker on the browser side could result in an activated service
worker visible in the JavaScript "then" method, although the worker is
expected to have not yet begun installation at that point.

This patch teaches ServiceWorker to wait for the registration promise to
resolve before processing state changes from the browser.

This patch won't have an effect until the Chromium side change also lands.

BUG=365252

Review URL: https://codereview.chromium.org/247263010

git-svn-id: svn://svn.chromium.org/blink/trunk@172459 bbb929c8-8fbe-4397-9dbb-9b2b20218538