Skip to content

browser context, working in 2021, not in 2025? #8263

Open
@j2l

Description

@j2l

According to https://stackoverflow.com/questions/66425664/nwjs-call-function-on-binary-file
if package.json:

{"name":"Demo",
"main":"index.html",
"version":"0.0.0",
"product_string":"Demo",
"window":{"icon":"./icon.png"}
}

js (in a binary.bin form):

function foo(){
    alert("its work!");
}

and index.html:

<script>
nw.Window.get().evalNWBin(null, 'binary.bin');
foo();
</script>

it should show an alert, right?

But I don't get the alert, but get in the console:

Uncaught Error: Unauthorized domain
    at <anonymous>
    at NWWindow.evalNWBinInternal (extensions::nw.Window:505:20)
    at NWWindow.evalNWBin (extensions::nw.Window:486:8)
    at index.html:200:17

I also tried using a main.js:

nw.Window.open('index.html', {}, function(win) {
    win.on('loaded', function() {
        // Evaluate the binary in the main frame of the new window
        win.evalNWBin(null, 'binary.bin');
        foo()
    });
});

It does the same thing, no alert. But no error though.

How to run the binary.bin into the browser context?
Thanks

PS: using Ubuntu 22.04, node v18.20.7, if it helps 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions