fix(zone.js): zone-mix should import correct browser module (#31628)

Close #31626

PR Close #31628
This commit is contained in:
JiaLiPassion 2019-07-19 01:42:23 +09:00 committed by Miško Hevery
parent 2bb9a65351
commit 87ce4e997b
4 changed files with 46 additions and 5 deletions

View File

@ -673,6 +673,10 @@ jobs:
# Run zone.js tools tests
- run: yarn --cwd packages/zone.js promisetest
- run: yarn --cwd packages/zone.js promisefinallytest
- run: yarn bazel build //packages/zone.js:npm_package &&
cp dist/bin/packages/zone.js/npm_package/dist/zone-mix.js ./packages/zone.js/test/extra/ &&
cp dist/bin/packages/zone.js/npm_package/dist/zone-patch-electron.js ./packages/zone.js/test/extra/ &&
yarn --cwd packages/zone.js electrontest
workflows:
version: 2

View File

@ -6,8 +6,5 @@
* found in the LICENSE file at https://angular.io/license
*/
import '../zone';
import '../common/promise';
import '../common/to-string';
import '../browser/browser';
import '../browser/rollup-main';
import '../node/node';

View File

@ -15,13 +15,16 @@
"test": "test"
},
"devDependencies": {
"domino": "2.1.2",
"mocha": "^3.1.2",
"mock-require": "3.0.3",
"promises-aplus-tests": "^2.1.2",
"typescript": "~3.4.2"
},
"scripts": {
"promisetest": "tsc -p . && node ./promise-test.js",
"promisefinallytest": "tsc -p . && mocha promise.finally.spec.js"
"promisefinallytest": "tsc -p . && mocha promise.finally.spec.js",
"electrontest": "cd test/extra && node electron.js"
},
"repository": {
"type": "git",

View File

@ -0,0 +1,37 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var domino = require('domino');
var mockRequire = require('mock-require');
var nativeTimeout = setTimeout;
require('./zone-mix');
mockRequire('electron', {
desktopCapturer: {getSources: function(callback) { nativeTimeout(callback); }},
shell: {openExternal: function(callback) { nativeTimeout(callback); }},
ipcRenderer: {on: function(callback) { nativeTimeout(callback); }},
});
require('./zone-patch-electron');
var electron = require('electron');
var zone = Zone.current.fork({name: 'zone'});
zone.run(function() {
electron.desktopCapturer.getSources(function() {
if (Zone.current.name !== 'zone') {
process.exit(1);
}
});
electron.shell.openExternal(function() {
console.log('shell', Zone.current.name);
if (Zone.current.name !== 'zone') {
process.exit(1);
}
});
electron.ipcRenderer.on(function() {
if (Zone.current.name !== 'zone') {
process.exit(1);
}
});
});