Skip to content

Commit

Permalink
fix(zone.js): zone-mix should import correct browser module (#31628)
Browse files Browse the repository at this point in the history
Close #31626

PR Close #31628
  • Loading branch information
JiaLiPassion authored and mhevery committed Jul 24, 2019
1 parent 0440dc9 commit f064045
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions packages/zone.js/lib/mix/rollup-mix.ts
Expand Up @@ -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';
5 changes: 4 additions & 1 deletion packages/zone.js/package.json
Expand Up @@ -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",
Expand Down
37 changes: 37 additions & 0 deletions packages/zone.js/test/extra/electron.js
@@ -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);
}
});
});

0 comments on commit f064045

Please sign in to comment.