feat(service-worker): include ServiceWorker version in debug info (#42622)
This commit includes the ServiceWorker version in the debug info shown at `/ngsw/state` to make it easier to know what version of the ServiceWorker script is controlling the page. PR Close #42622
This commit is contained in:
parent
4962ef5330
commit
53fe557da7
|
@ -171,6 +171,7 @@ is `ngsw/state`. Here is an example of this debug page's contents:
|
|||
```
|
||||
NGSW Debug Info:
|
||||
|
||||
Driver version: 13.3.7
|
||||
Driver state: NORMAL ((nominal))
|
||||
Latest manifest hash: eea7f5f464f90789b621170af5a569d6be077e5c
|
||||
Last update check: never
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import {Adapter} from './adapter';
|
||||
import {Debuggable, DebugLogger} from './api';
|
||||
|
||||
const SW_VERSION = '0.0.0-PLACEHOLDER';
|
||||
const DEBUG_LOG_BUFFER_SIZE = 100;
|
||||
|
||||
interface DebugMessage {
|
||||
|
@ -37,6 +38,7 @@ export class DebugHandler implements DebugLogger {
|
|||
|
||||
const msgState = `NGSW Debug Info:
|
||||
|
||||
Driver version: ${SW_VERSION}
|
||||
Driver state: ${state.state} (${state.why})
|
||||
Latest manifest hash: ${state.latestHash || 'none'}
|
||||
Last update check: ${this.since(state.lastUpdateCheck)}`;
|
||||
|
|
|
@ -1237,19 +1237,19 @@ describe('Driver', () => {
|
|||
describe('serving ngsw/state', () => {
|
||||
it('should show debug info (when in NORMAL state)', async () => {
|
||||
expect(await makeRequest(scope, '/ngsw/state'))
|
||||
.toMatch(/^NGSW Debug Info:\n\nDriver state: NORMAL/);
|
||||
.toMatch(/^NGSW Debug Info:\n\nDriver version: .+\nDriver state: NORMAL/);
|
||||
});
|
||||
|
||||
it('should show debug info (when in EXISTING_CLIENTS_ONLY state)', async () => {
|
||||
driver.state = DriverReadyState.EXISTING_CLIENTS_ONLY;
|
||||
expect(await makeRequest(scope, '/ngsw/state'))
|
||||
.toMatch(/^NGSW Debug Info:\n\nDriver state: EXISTING_CLIENTS_ONLY/);
|
||||
.toMatch(/^NGSW Debug Info:\n\nDriver version: .+\nDriver state: EXISTING_CLIENTS_ONLY/);
|
||||
});
|
||||
|
||||
it('should show debug info (when in SAFE_MODE state)', async () => {
|
||||
driver.state = DriverReadyState.SAFE_MODE;
|
||||
expect(await makeRequest(scope, '/ngsw/state'))
|
||||
.toMatch(/^NGSW Debug Info:\n\nDriver state: SAFE_MODE/);
|
||||
.toMatch(/^NGSW Debug Info:\n\nDriver version: .+\nDriver state: SAFE_MODE/);
|
||||
});
|
||||
|
||||
it('should show debug info when the scope is not root', async () => {
|
||||
|
@ -1258,7 +1258,7 @@ describe('Driver', () => {
|
|||
new Driver(newScope, newScope, new CacheDatabase(newScope, newScope));
|
||||
|
||||
expect(await makeRequest(newScope, '/foo/bar/ngsw/state'))
|
||||
.toMatch(/^NGSW Debug Info:\n\nDriver state: NORMAL/);
|
||||
.toMatch(/^NGSW Debug Info:\n\nDriver version: .+\nDriver state: NORMAL/);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue