Last active
February 8, 2018 13:14
-
-
Save m-rousse/de42a69db1405d82a919689778329c12 to your computer and use it in GitHub Desktop.
Proof of bug, chrome devtool protocol and angular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html ng-app="testModule"> | |
<head></head> | |
<body ng-controller="MainController as vm"> | |
<button ng-click="vm.onNgClick()"></button> | |
<ui-view></ui-view> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.2/angular-ui-router.min.js"></script> | |
<script> | |
angular | |
.module('testModule', ['ui.router']) | |
.config(function ($compileProvider) { | |
$compileProvider.debugInfoEnabled(true); | |
}) | |
</script> | |
<script> | |
angular | |
.module('testModule') | |
.config(function ($stateProvider) { | |
$stateProvider.state({ | |
name: 'next', | |
url: '/next', | |
template: '<button id="next" ng-click="vm.onNgClick()"></button>', | |
controller: 'NextController', | |
controllerAs: 'vm', | |
}) | |
}) | |
.controller('MainController', function ($state) { | |
this.onNgClick = function () { | |
$state.go('next'); | |
} | |
}) | |
.controller('NextController', function ($state) { | |
this.onNgClick = function () { | |
console.error('Second page'); | |
} | |
}) | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CDP = require('chrome-remote-interface'); | |
CDP({port:9223}, async (client) => { | |
const {Page} = client; | |
try { | |
await Page.enable(); | |
await Page.navigate({url: 'http://localhost:8123/index.html'}); | |
await Page.loadEventFired(); | |
console.log("Page 1 loaded"); | |
await Page.navigate({url: 'http://localhost:8123/index.html#!/next'}); | |
console.log('navigate 2 finished') | |
await Page.loadEventFired(); | |
console.log("Page 2 loaded"); | |
} catch (err) { | |
console.error(err); | |
} finally { | |
client.close(); | |
} | |
}).on('error', (err) => { | |
console.error(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment