Access to filesystem with javascript in a QWebview - javascript

I have a to do a game launcher.
I use a QWebview initialized in c++ and I use javascript / Html to build my menus.
I want to execute a binary in filesystem when I click on a button.
Is it possible ? I didn't find any solution.

You can use QWebFrame::addToJavaScriptWindowObject() to make a C++ object visible from Javascript code in your page.
Create a C++ object and add a slot to that object that uses QProcess to start the binary you want. Make it visible calling addToJavaScriptWindowObject(). Now you can call the slot from javascript code and pass the path to the binary in it.

Related

User controll Webassembly access calls from c++ to java script

I am wondering if there is a way to restrict a c++ compiled wasm file to NOT be able to call any javascript from within the c++ code. The idea is to prove to the user that the c++ wasm compiled file is not calling any javascript methods from within c++ i.e. it is only taking the input that has been provided from javascript trough some linear memory input working on it an giving back some result, but during that process no call should be possible to java script from within the c++ code. i.e. to put the wasm in some kind of jail mode where the binary is not able to call any javascript AT ALL! This is important in cases where the wasm produces itself some binary output, and it is unknown what is in that output. Basically i want to make sure that the "add2Strings" method that is called on the webassembly is not doing something else except adding "String1+String2" and returning some ByteBuffer/vector that represent the result (String1+String2) and not something like "String1+String2+FingerprintString+emailAddress" which can later be send trough javascript over the network god knows where.
I am wondering if there is a way to restrict a c++ compiled wasm file to NOT be able to call any javascript from within the c++ code
This is already default WebAssembly behavior. It can't execute any JavaScript function that you don't explicitly pass to it in the imports object.

Blue Prism: Cannot Iterate through JSON items withing injected JS script

So I am trying to iterate through JSON items via injected script. And BP is throwing me a syntax error that it is incapable of compiling my code.
code:
function fillInputs(json){
alert(json[0].Email);
}
through Invoke I am giving [JSON] variable that has a well structured JSON object which I created with help of Utility - JSON and it is working fine on test websites. But BP will not initialize specifically this part / alert(json[0].Email); / and is throwing a standard error which usually means syntax errors.
Could someone tell me if there is a better way to iterate through JSON objects with Blue Prism injected Javascript code and if I am choosing a harsh way to do it?
This is easily accomplished using the built-in Internet Explorer browser automation features provided out of the box in Blue Prism.
For organization, place your custom Javascript in a data item of type text on your action page:
Then use a Navigate stage to insert the fragment and invoke it:
With your current snippet, you'll get a nice alert window in Internet Explorer:
A good way to retrieve this data using Blue Prism would be to use the Javascript snippet you insert to create a hidden input element, the value of which is set a string representation of the JSON data you're attempting to exfiltrate.
You can then create a manual Application Modeler entry based off of an existing one to target this hidden element, and then use a Read stage to copy the data into a Data Item within Blue Prism. Further, you can use the bundled JSON object (or write your own as a wrapper around a better VB/C# library) to extract and manipulate the data within as you wish.

How to access one JS file from a function inside a JS file

So, I am making a "ModReady" version of my JavaScript game where you can easily mod a game. The point is to click a button inside a ModReady version of a game, type the filepath of the mod you want to run, and the JavaScript executes it.
I have a problem though. I don't think you can run a separate .js file from inside a function.
Is this possible to do?
Depends on where the game is relative to the mod authors file. The short answer is yes, but you have to be a little cunning if the mods script doesn't exist in the same place as yours.
The safest and easiest method would be to offer a version of the code base which others can download and mod themselves.
Alternatively theres several methods of running code cross browser, i wouldn't advise letting other peoples code reside on your server.
The simplest method would be similar to the way code pen or JSfiddle work, you have a text box which the mod adds the code to. Then either run your game in an iframe with the text box contents included in a script element, or store the string in a HTML 5 local storage element, load the game page querying the local storage and add the local storage string to a new script element.

How do I call an ActionScript class from an included SWF file from javascript with AIR app?

I have an AIR app that includes blooddy_crypto_0.3.5.swf
<script src="lib/MD5/blooddy_crypto_0.3.5.swf" type="application/x-shockwave-flash"></script>
I want to calculate the MD5 hash of a byte array I'll read via a filestream.
What I can't figure out is HOW to call the Md5 function.
swfdump blooddy_crypto_0.3.5.swf
shows
by/blooddy/crypto/MD5", lazy load
So, how do I instantiate this function from my javascript?
I've read How to access Actionscript from Javascript in Adobe AIR
and How to invoke an ActionScript method from JavaScript (HTMLLoader) object in AIR?
But it didn't really help, I'm nOT trying to manipulate a DOM object but run a piece of Math ;)
Any help appreciated.

Calling a function in a JavaScript file with Selenium IDE

So, I'm running these Selenium IDE tests against a site I'm working on. Everything about the tests themselves is running fine, except I would like to do a bit of clean-up once I'm done. In my MVC3 Razor based site, I have a JavaScript file with a function that gets a JsonResult from a Controller of mine. That Controller handles the database clean-up that Selenium IDE otherwise couldn't handle.
However, I'm having a hard time finding any sort of documentation on how to do this. I know I can do JavaScript{ myJavascriptGoesHere } as one of the Values for a line in the test, but I can't seem to find a way to tell it to go find my clean-up function.
Is it even possible for Selenium IDE to do this sort of thing?
If it comes down to it, I can just make a separate View to handle the clean-up, but I'd really like to avoid that if possible.
Thanks!
If you want to execute your own JavaScript function that exists in your test page from Selenium IDE, you need to make sure you access it via the window object. If you look at the reference for storeEval for instance, it says:
Note that, by default, the snippet will run in the context of the
"selenium" object itself, so this will refer to the Selenium object.
Use window to refer to the window of your application, e.g.
window.document.getElementById('foo')
So if you have your own function e.g. myFunc(). You need to refer to it as window.myFunc().
This can be very handy for exercising client-side validation without actually submitting the form, e.g. if you want to test a variety of invalid and valid form field values.
If you use runScript, that should already run in the window's context.
This works for me.
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
string title = (string)js.ExecuteScript("myJavascriptGoesHere");
Make sure your javascript works first before using it here!
Actually to access your page javascript space, you need to get the real window of your page : this.browserbot.getUserWindow()
See this statement to get the jQuery entry point in your page (if it has jQuery of course ^^ )
https://stackoverflow.com/a/54887281/2143734

Categories

Resources