GoogleChromeLabs / carlo

Web rendering surface for Node applications
Apache License 2.0
9.32k stars 309 forks source link

Is there a way to cancel navigation intercepted by HttpRequest? #129

Closed gadamsgh closed 5 years ago

gadamsgh commented 5 years ago

Is there a way to simply cancel a navigation?

Example main.js:

const carlo = require('carlo');

(async () => {
    const app = await carlo.launch({args:['--auto-open-devtools-for-tabs']});
    app.on('exit', () => process.exit());
    app.serveFolder(__dirname);
    app.serveHandler(async function (request) {
        request.url() === 'http://www.github.com/' ? request.abort() : request.continue();
    });
    await app.load('https://www.google.com');
})();

In this example, we launch to www.google.com and then navigate to github.com from the console. window.location = 'http://www.github.com/'

What I'd like to do in this case is leave the user where they were before attempting to navigate, without reloading. Is this possible? image

pavelfeldman commented 5 years ago

Fixed as https://github.com/GoogleChromeLabs/carlo/commit/17d972c6d43b0c2ede063b334c723f743dfbaa5c