Skip to content

Commit 6c375b9

Browse files
committed
Merge branch 'master' into wuandy/Bundles
# Conflicts: # integration/messaging/test/utils/openNewTab.js # packages/firestore/src/core/component_provider.ts # packages/firestore/src/local/indexeddb_persistence.ts # packages/firestore/src/local/local_serializer.ts # packages/firestore/src/platform/platform.ts # packages/firestore/src/platform_browser/browser_platform.ts # packages/firestore/src/platform_node/node_platform.ts # packages/firestore/src/remote/serializer.ts # packages/firestore/test/unit/local/persistence_test_helpers.ts # packages/firestore/test/unit/specs/spec_test_components.ts # packages/firestore/test/util/test_platform.ts
2 parents d3f0ab4 + 1791a9b commit 6c375b9

File tree

317 files changed

+16675
-5295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

317 files changed

+16675
-5295
lines changed

.github/workflows/test-all.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
run: yarn build
2626
- name: Run unit tests
2727
run: xvfb-run yarn test:ci
28+
env:
29+
FCM_TEST_PROJECT_SERVER_KEY: $${{secrets.FCM_TEST_PROJECT_SERVER_KEY}}
2830
- name: Generate coverage file
2931
run: yarn ci:coverage
3032
- name: Run coverage

.github/workflows/test-changed.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ jobs:
2828
run: yarn build
2929
- name: Run tests on changed packages
3030
run: xvfb-run yarn test:changed
31+
env:
32+
FCM_TEST_PROJECT_SERVER_KEY: $${{secrets.FCM_TEST_PROJECT_SERVER_KEY}}

common/api-review/app-exp.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export function _registerComponent(component: Component): boolean;
5858
// @public
5959
export function registerVersion(libraryKeyOrName: string, version: string, variant?: string): void;
6060

61+
// @internal (undocumented)
62+
export function _removeServiceInstance<T extends Name>(app: FirebaseApp, name: T, instanceIdentifier?: string): void;
63+
6164
// @public
6265
export const SDK_VERSION: string;
6366

common/api-review/app-types-exp.api.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ export interface FirebaseOptions {
5353
storageBucket?: string;
5454
}
5555

56+
// @internal (undocumented)
57+
export interface _FirebaseService {
58+
// (undocumented)
59+
app: FirebaseApp;
60+
delete(): Promise<void>;
61+
}
62+
5663
// @public (undocumented)
5764
export interface PlatformLoggerService {
5865
// (undocumented)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## API Report File for "@firebase/functions-exp"
2+
3+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4+
5+
```ts
6+
7+
import { FirebaseApp } from '@firebase/app-types-exp';
8+
import { Functions } from '@firebase/functions-types-exp';
9+
import { HttpsCallable } from '@firebase/functions-types-exp';
10+
import { HttpsCallableOptions } from '@firebase/functions-types-exp';
11+
12+
// @public
13+
export function getFunctions(app: FirebaseApp, region?: string): Functions;
14+
15+
// @public
16+
export function httpsCallable(functionsInstance: Functions, name: string, options?: HttpsCallableOptions): HttpsCallable;
17+
18+
// @public
19+
export function useFunctionsEmulator(functionsInstance: Functions, origin: string): void;
20+
21+
22+
// (No @packageDocumentation comment for this package)
23+
24+
```

config/karma.saucelabs.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ const packageConfigs = {
4949
messaging: {
5050
// Messaging currently only supports these browsers.
5151
browsers: ['Chrome_Windows', 'Firefox_Windows', 'Edge_Windows']
52+
},
53+
firestore: {
54+
browsers: [
55+
'Chrome_Windows',
56+
'Firefox_Windows',
57+
'Edge_Windows',
58+
'Safari_macOS'
59+
]
5260
}
5361
};
5462

@@ -170,7 +178,8 @@ module.exports = function(config) {
170178
'packages/polyfill/index.ts': ['webpack', 'sourcemap'],
171179
'**/test/**/*.ts': ['webpack', 'sourcemap'],
172180
'**/*.test.ts': ['webpack', 'sourcemap'],
173-
'packages/firestore/test/**/bootstrap.ts': ['webpack', 'babel'],
181+
// Restore when ready to run Firestore unit tests in IE.
182+
// 'packages/firestore/test/**/bootstrap.ts': ['webpack', 'babel'],
174183
'integration/**/namespace.*': ['webpack', 'babel', 'sourcemap']
175184
},
176185

config/webpack.test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -18,6 +18,12 @@
1818
const path = require('path');
1919
const webpack = require('webpack');
2020

21+
/**
22+
* A regular expression used to replace Firestore's platform specific modules,
23+
* which are located under 'packages/firestore/src/platform/'.
24+
*/
25+
const FIRESTORE_PLATFORM_RE = /^(.*)\/platform\/([^.\/]*)(\.ts)?$/;
26+
2127
module.exports = {
2228
mode: 'development',
2329
devtool: 'source-map',
@@ -77,6 +83,15 @@ module.exports = {
7783
extensions: ['.js', '.ts']
7884
},
7985
plugins: [
86+
new webpack.NormalModuleReplacementPlugin(
87+
FIRESTORE_PLATFORM_RE,
88+
resource => {
89+
resource.request = resource.request.replace(
90+
FIRESTORE_PLATFORM_RE,
91+
'$1/platform/browser/$2.ts'
92+
);
93+
}
94+
),
8095
new webpack.EnvironmentPlugin([
8196
'RTDB_EMULATOR_PORT',
8297
'RTDB_EMULATOR_NAMESPACE'

integration/browserify/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test:ci": "node ../../scripts/run_tests_in_ci.js"
99
},
1010
"dependencies": {
11-
"firebase": "7.14.4"
11+
"firebase": "7.15.4"
1212
},
1313
"devDependencies": {
1414
"@babel/core": "7.9.6",

integration/firebase-typings/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test:ci": "node ../../scripts/run_tests_in_ci.js"
88
},
99
"dependencies": {
10-
"firebase": "7.14.4"
10+
"firebase": "7.15.4"
1111
},
1212
"devDependencies": {
1313
"typescript": "3.8.3"

integration/firestore/gulpfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -51,6 +51,7 @@ function copyTests() {
5151
testBase + '/integration/api/*.ts',
5252
testBase + '/integration/util/events_accumulator.ts',
5353
testBase + '/integration/util/helpers.ts',
54+
testBase + '/integration/util/settings.ts',
5455
testBase + '/util/equality_matcher.ts',
5556
testBase + '/util/promise.ts'
5657
],

integration/messaging/download-browsers.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -18,14 +18,9 @@
1818
const seleniumAssistant = require('selenium-assistant');
1919

2020
console.log('Starting browser download - this may take some time.');
21-
Promise.all([
22-
seleniumAssistant.downloadLocalBrowser('chrome', 'stable', 48),
23-
seleniumAssistant.downloadLocalBrowser('chrome', 'beta', 48),
24-
seleniumAssistant.downloadLocalBrowser('chrome', 'unstable', 48),
25-
seleniumAssistant.downloadLocalBrowser('firefox', 'stable', 48),
26-
seleniumAssistant.downloadLocalBrowser('firefox', 'beta', 48),
27-
seleniumAssistant.downloadLocalBrowser('firefox', 'unstable', 48)
28-
])
21+
// TODO: enable firefox testing once figure out how to give notification permission with SE webdriver.
22+
// TODO: Run the integration test against multiple major chrome versions to ensure backward compatibility
23+
Promise.all([seleniumAssistant.downloadLocalBrowser('chrome', 'stable', 80)])
2924
.then(() => {
3025
console.log('Browser download complete.');
3126
})

integration/messaging/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"version": "0.2.1",
55
"scripts": {
66
"pretest:manual": "node ./download-browsers.js",
7-
"test": "echo 'Tests disabled due to flakiness'",
7+
"test": "mocha --exit",
88
"test:manual": "mocha --exit"
99
},
1010
"dependencies": {
11-
"firebase": "7.14.4"
11+
"firebase": "7.15.4"
1212
},
1313
"devDependencies": {
1414
"chai": "4.2.0",
15-
"chromedriver": "80.0.2",
15+
"chromedriver": "^83.0.0",
1616
"express": "4.17.1",
1717
"geckodriver": "1.19.1",
1818
"mocha": "7.1.2",

integration/messaging/test/static/app.js

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
const EIGHT_DAYS_IN_MS = 8 * 86400000;
19-
2018
/**
2119
* This class just wraps the expected behavior or a demo app that will
2220
* be orchestrated by selenium tests (Although manual use of the demo will
@@ -36,40 +34,49 @@ class DemoApp {
3634
this._triggerDeleteToken = this.triggerDeleteToken;
3735
this._triggerGetToken = this.triggerGetToken;
3836
this._triggerTimeForward = this.triggerTimeForward;
37+
this._clearInstanceForTest = this.clearInstanceForTest;
38+
this.appendMessage = this.appendMessage;
3939

4040
// Initialize Firebase
4141
firebase.initializeApp(firebaseConfig);
4242

4343
this._messaging = firebase.messaging();
4444

45-
if (options.applicationKey) {
46-
this._messaging.usePublicVapidKey(options.applicationKey);
45+
if (options.vapidKey) {
46+
console.debug('VapidKey is provided to the test app. ');
47+
this._messaging.usePublicVapidKey(options.vapidKey);
48+
} else {
49+
console.debug('VapidKey is not specified. Skip setting it');
4750
}
4851

4952
if (options.swReg) {
53+
console.debug('ServiceWorker is provided to the test app');
5054
this._messaging.useServiceWorker(options.swReg);
55+
} else {
56+
console.debug(
57+
'ServiceWorker is not specified. The default ServiceWorker will be used.'
58+
);
5159
}
5260

53-
this._messaging.onMessage(payload => {
54-
console.log(`Message received: `, payload);
55-
this._messages.push(payload);
61+
this._messaging.onMessage(message => {
62+
this.appendMessage(message);
5663
});
5764

58-
// Initializa state of token
59-
this._messaging
60-
.requestPermission()
61-
.then(() => this._messaging.getToken())
62-
.then(
63-
token => {
64-
console.log('getToken() worked: ', token);
65-
this._token = token;
66-
},
67-
err => {
68-
console.log('getToken() failed: ', err.message, err.stack);
69-
this._errors.push(err);
70-
this._token = null;
71-
}
72-
);
65+
this._messaging.getToken().then(
66+
token => {
67+
console.log('Test app getToken() succeed. Token: ', token);
68+
this._token = token;
69+
},
70+
err => {
71+
console.log('Test app getToken() failed: ', err.message, err.stack);
72+
this._errors.push(err);
73+
this._token = null;
74+
}
75+
);
76+
}
77+
78+
appendMessage(payload) {
79+
this._messages.push(payload);
7380
}
7481

7582
async triggerDeleteToken(token) {
@@ -95,10 +102,15 @@ class DemoApp {
95102
return this._token;
96103
}
97104

98-
async triggerTimeForward() {
105+
triggerTimeForward() {
99106
this._clock.tick(EIGHT_DAYS_IN_MS);
100107
}
101108

109+
clearInstanceForTest() {
110+
this._errors = [];
111+
this._messages = [];
112+
}
113+
102114
get token() {
103115
return this._token;
104116
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
// Test project managed by the FCM team
19+
const PUBLIC_VAPID_KEY =
20+
'BNjjus3nz38aYtbDLVfunY3VULg0Yq5T4GXWd7iDDmeqWCUNqfrK1eiKVdoT0VncLuCjfJ1GmdfmNZz-AjHfkxM';
21+
const FIREBASE_CONFIG = {
22+
apiKey: 'AIzaSyBpIe0xyUNHOwtE_go32NmUJF4acsc6S6c',
23+
projectId: 'fcm-web-sdk-test',
24+
messagingSenderId: '750970317741',
25+
appId: '1:750970317741:web:f382be3155e250906a4f24'
26+
};
27+
28+
const TAG = 'FCM_INTEGRATION_TEST: ';
29+
const EIGHT_DAYS_IN_MS = 8 * 86400000;
30+
const TEST_DB = 'FCM_INTEGRATION_TEST_DB';
31+
const TEST_DB_VERSION = 1;
32+
const BACKGROUND_MESSAGES_OBJECT_STORE = 'background_messages';
33+
// indexDb object store creation require a "primary key", "ndx" is used.
34+
const BACKGROUND_MESSAGES_OBJECT_STORE_PRIMARY_KEY = 'ndx';
35+
const BACKGROUND_MESSAGES_OBJECT_STORE_DEFAULT_NDX = 'default_ndx';
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
<html>
2-
<head>
3-
<title>FCM Demo</title>
4-
<meta name="viewport" content="width=device-width,initial-scale=1">
5-
</head>
6-
<body>
7-
<h1>Default SW</h1>
8-
<script src="/firebase/firebase-app.js"></script>
9-
<script src="/firebase/firebase-messaging.js"></script>
10-
<script src="/app.js"></script>
11-
<script src="../valid-no-vapid-key/firebaseConfig.js"></script>
12-
<script src="https://cdnjs.cloudflare.com/ajax/libs/sinon.js/4.1.3/sinon.min.js"></script>
13-
<script>
14-
window.__test = new window.DemoApp(window.firebaseConfig);
15-
</script>
16-
</body>
17-
</html>
2+
<head>
3+
<title>FCM Demo</title>
4+
<meta name="viewport" content="width=device-width,initial-scale=1" />
5+
</head>
6+
<body>
7+
<h1>Default SW</h1>
8+
<script src="/firebase-app.js"></script>
9+
<script src="/firebase-messaging.js"></script>
10+
<script src="../app.js"></script>
11+
<script src="../constants.js"></script>
12+
<script src="https://cdnjs.cloudflare.com/ajax/libs/sinon.js/4.1.3/sinon.min.js"></script>
13+
<script>
14+
window.__test = new window.DemoApp(FIREBASE_CONFIG, {
15+
vapidKey: PUBLIC_VAPID_KEY
16+
});
17+
</script>
18+
</body>
19+
</html>

0 commit comments

Comments
 (0)