Dart lang: How do you browser feature test for file uploading & file reading APIs? - dart

How do you feature test for browser support using Dart? Things that are common to test for in Javascript. It is unfortunately still a necessary evil.
For instance, how do you write a test if the browser supports 'XMLHttpRequestUpload' so that you can fallback to supported features?
Also, how do you test for 'FileReader', 'Worker', 'ArrayBuffer', 'DataView', 'Uint8Array', 'Float32Array', ... ?
In Javascript, you can test if the objects are available in the global namespace (Window, etc).

To check if you can access the file system use the FileSystem.supported field. Similarly for workers see Worker.supported.
Since Dart targets IE9+, I think the other API's you've listed are already supported cross browser.

Related

how to specify configuration(specifically reporter to be used) in playwright-dotnet

I'm beginner in C#.net. Is there a way to have a configuration file for playwright-dotnet similar to playwright.conf.js(js version). As the config file made it easier to specify most configurations in one place!
There is no mention of config in playwright documentation for .net version. I became aware of ".runsettings" for playwright-dotnet which I used to specify browsers to be used, but couldn't get a proper understanding on report integration!

Dartium and it's use of dart:io

I am building a feature-rich standalone application using dart. I picked dart since it seemed to allow not only the standard development approach for webapps but also to access system resources (such as nodejs does). One of my requirements is file io or database access (which again requires file io). Dartium however does not allow the use of the dart:io package (only in servermode is this library accessible). Can anybody think of a workaround, a change to the dart environment or the chromium environment to allow this ? Maybe a custom compiled dartVM in the browser environemnt.
Basically a way to use database connections in a dart standalone app. A REST wrapper is only an option if this code could get generated automatically.
I am not clear if such a thing is possible or if chromium will prevent any approach to access system resources.
Yes in standalone mode dart you can use files, and also TCP socket, and web socket.
So you can connect to databases. (for example to MySQL: https://github.com/jamesots/sqljocky)
In browser mode you can use built-in databases dart:indexed_db or dart:web_sql.
You can also use web-socket protocol
Maybe you can use websocket to connect with local or remote database.

DART: What is best practice for config settings

Interpreted languages such as PHP allow a separate file, often called config.php, to contain string constants such as server names. This facilitates deployment, as the config file is simply not uploaded when the code is updated - the server names, e.g. for REST transactions, are typically different in the deployment environment.
In Dart, since it is compiled, this approach does not work. If there are server name constants which are referred to in the HTML via {{ }}, it seems the code must be recompiled before deployment.
Is there a way to specify string constants in such a way to avoid this recompilation requirement?
There are a couple of options I can think of:
One trick is to put configuration in a map keyed by hostname. At runtime, look up the configuration from the map, using window.location as a key. This will allow configuration to be baked into the Dart source, yet still allow different values to be specified for different environments.
If you want to be able to change your configuration after compilation, you can embed it as JSON within the HTML source, or load it via an HTTP request. (This isn't using a constant as asked, however, by definition it's not possible to change a constant after compile time)
Ok, so short answer is "You can't" - at the moment. But the Dart team are aware of this limitation, and are discussing it in dartlang as per the comment above.

Why is WSCript object not known to my script that's controlled by a custom IScriptControl?

I am using someone else's library that provides its own scripting host instance, it appears.
This lib provides me with functions to define the type of scripting language such as "jscript" and "vbscript", and I can supply it with script code and have that executed, with passing arguments in and back. So, basically, it works.
However, when I try to access the "WScript" object, I get an exception saying that this keyword is undefined.
The developer, not knowing much about this either (he only made this lib for me because I do not want to deal with Windows SDKs right now), told me that he is using "IScriptControl" for this.
Oh, and the lib also provides flags to allow "only safe subset" and "allow UI", which I set to false and true, respectively.
Does that ring a bell with anyone? Do a user of IScriptControl have to take extra steps in order to make a WScript object available? Or, can he use IScriptControl in a way that this is supplied automatically, just as when running the same script from wscript.exe?
Basically, all I need is the WScript.CreateObject function in order to access another app's API via COM.
I don't know why WScript is not known, but I suspect it is because the script host doesn't provide it. Maybe only wscript.exe does this.
If you are using Javascript, to create an object you can use new ActiveXObject(). If you are using VBScript, you can just use CreateObject.
See this article for some background.

Firefox extension: Embed javascript in a webpage

I want to insert some script into every page, which have some functions that will be called by the modified HTML of that page, using a Firefox extension. I am able to insert the JavaScript into the head of the HTML, and also modify the page, but the java script functions are not called by the onmouseover event.
Does someone has any pointer on how to do that, using java script in local extension or as a online resource.
No GreaseMonkey, I need to do it with my plugin and not ask user to install greasemonkey, my plugin and the scripts.
Greasemonkey does this. It's excellent!
Make a Greasemonkey script. See Userscripts.org for lots of example ones to work off.
Why not use Greasemonkey? It allows you to execute javascript on any page on Firefox, and if executing the code you enter isn't good enough you could dynamically add links to the head, too.
you can modify the DOM using Firebug. I am not sure if you can load files locally.. sounds malicious. Also, you can just run arbitrary javascript commands in the Firebug console (a la python/ruby console)
There are some Greasemonkey-to-extension "compilers" (or extension-wrappers) out there:
Arantius's GM compiler
Gina Trapani's multiple-GM-script compiler
I've used the first one with extensive internal tweaking over time. However, I don't believe the compiler is actively maintained (default max-version is only 3.0), so may not be up-to-date with the latest GreaseMonkey, or FireFox.
I think Gina Trapani's is more designed for multiple scripts targetting the same domain, but I haven't used it.
Neither of these is a "GreaseMonkey solution" per se, as the end-user never has to install GreaseMonkey. They get a real-live FireFox extension. The core is very similar to GM, but you can change or add as much as you like.

Resources