Create object from dll then calling a method - dll

I am trying to call some methods from a dll library. I have found some examples in JavaScript and c++ . I don't know how to use c++ so let me show you what I have worked out for the JavaScript example:
<html>
<head>
<title>Palm Pad</title>
</HEAD>
<script type="text/javascript" language="JavaScript1.2">
if(window.ActiveXObject) {
//var ActiveHomeObj = new ActiveXObject("X10.ActiveHome");
} else {
alert("This script was design to work with Internet Explore 5 and up");
}
function getUSCode(Button1,OnOff)
{
ActiveHomeObj.SendAction("sendplc","A1 on");
}
</script>
<body>
click here to see if method runs
<OBJECT ID="ActiveHomeObj" classid="CLSID:001000AF-2DEF-0208-10B6-DC5BA692C858" codebase="ahscript.dll" type="application/x-oleobject"></OBJECT>
</body>
</html>
as you can see this is a very simple html page with just one JavaScript function that gets executed when clicking on the link. The problem with this script is that it only works with internet explorer and when using it I get the warning.
If I use internet explorer and I enable the blocked content I am able to execute the SendAction method on the ahscript.dll library.
I will like to run this with other browsers as well so it will be nice if I can create a .bat file that would enable me to do the same thing. Or a vbs script. Or any other script...
if for some reason you know AutoIt here is what I have tried out with it:
AutoIt:
DllCall("ahscript.dll","none","SendAction","str","sendplc","str", "A1 on")
and
$o = ObjCreate("C:\Users\Virgilio\Desktop\x10\ahscript.dll")
$o.SendAction("sendplc","A1 on")
in vbs I have treid something similar.
How could I create an executable file that when executing it I can get the same result that if I where to open the html file in internet explorer then enable the warning and lastly executing the javascrip function?

Sorry, you're out of luck here.
First, ActiveXObject is specific to Internet Explorer. Firefox and Chrome do not support it. You can use special plugins for Firefox and Chrome that will enable an IE tab, but that is still IE.
In addition, ActiveX/COM is specific to Windows. You can use ActiveX/COM from Wine, but it is not natively supported by any other OS.

Related

Run Mocha HTML Tests in Browserstack / DOM Testing in Cloud

I'm trying to run DOM tests that I have written using Mocha and Chai for assert on Browserstack.
I have an HTML file test.html that looks like this:
<body>
<div id="mocha"></div>
<script src="https://unpkg.com/chai/chai.js"></script>
<script src="https://unpkg.com/mocha/mocha.js"></script>
<script class="mocha-init">
mocha.setup('bdd');
mocha.checkLeaks();
assert = chai.assert;
</script>
<script src="MY_DOM_TESTS.js"></script>
<script class="mocha-exec">
mocha.run();
</script>
</body>
When I open this file in the browser locally, it runs through and shows me that all tests pass. My question now is how I can run it in one of the testing clouds, for example Browserstack.
They seem to have many adapters and plugins, but nothing explains this simple use case of DOM tests in an HTML file. Everything seems to be about js files exclusively, but not for HTML files.
I have tried using Karma with their plugins karma-mocha and karma-browserstack-launcher, to no avail. I tried having Karma run this simple test file but not even that seems to work:
module.exports = function (config) {
config.set({
frameworks: ['mocha', 'chai'],
files: [
'./tests/test.html',
],
client: {
mocha: {
reporter: 'html',
ui: 'bdd',
},
},
Question: How can I run DOM tests using above HTML file in Browserstack (or any other Selenium testing cloud for that matter)?
I have figured it out. You need to use their local testing (the name is misleading), which basically opens a local server and pipes through local files to browserstack. I created a minimum example here on how to run mocha dom tests inside an HTML file on browserstack:
https://github.com/fritzfr/mocha-html-browserstack-bridge
Thank you for showing your interest in running tests on the remote cloud using Browserstack.
I did read through your query and could find that you want to run HTML DOM Tests on Browserstack, however, that is NOT supported and would require you to use a JS testing framework and write your tests accordingly in order to run tests.
Also, the documents you have referred are the required necessity in order to run JS Tests.
Please note you can use different Javascript unit testing frameworks such as QUnit, Jasmine, Mocha, and others to write our first unit test, and the same you can refer to the following documentation:
https://www.browserstack.com/docs/automate/javascript-testing/getting-started
Regards,
Browserstack Support

Why in Opera the 'chrome_url_overrides' is not allowed for specified extension ID?

I am making a cross-browser extension, which overrides the standard "New Tab" page.
There is a manifest.json key for that, called chrome_url_overrides:
"chrome_url_overrides": { "newtab": "index.html" }
It works in Chrome and Firefox! But in Opera (45.0) the following error occurs when I try to load the extension:
'chrome_url_overrides' is not allowed for specified extension ID.
Based on what I've read in the MDN chrome_url_overrides docs, Opera supports that.
Now I'm not sure if Opera doesn't allow that in general, or if there is a way to activate it?
Edit: I found a similar, unanswered yet, 3-months-old thread in the Opera Forums.
Actually Opera now officially does not support chrome_url_overrides. A piece of evidence can be found on the MDN page that you referenced and it was confirmed by an Opera representative in their forum.
A potential workaround for achieving a new tab extension in Opera (actually this should work in other browsers too) is to use a background script with the following code:
const redirectURLS = [
"opera://startpage/",
"browser://startpage/",
"chrome://startpage/"
];
chrome.tabs.onCreated.addListener(function(tab) {
for (let i = 0; i < redirectURLS.length; i++) {
if (tab.url === redirectURLS[i]) break; // user is trying to open startpage
if (i == redirectURLS.length - 1) return; // Tab is not trying to open a startpage
}
chrome.tabs.update(tab.id, { url: "index.html" });
});
Having this will check if the user tries to open a new tab and if this is the case it will open the custom index.html page that came with installing the plugin instead. It's a hacky and dirty and not sure if it's going to be accepted by Opera but still, this may be a path of salvation for someone desperately trying to get a new tab extension live among the other Opera Addons.
Fun fact: Opera developed and distributed an addon which helps you install chrome extension from chrome extension store on Opera but the new tab extensions don't work and fail upon installation with the following message:
[Compatibility notice]
Please, be aware that this extension requires APIs that are not supported in Opera.
It still can work in Opera, so complete installation to verify.
Opera's Acceptance Criteria say that:
Extensions cannot replace Opera’s default start page.
Even if you manage to accomplish your aim and replace the standard "New Tab" page, then the extension will not pass moderation.
Workarounds include assigning a keyboard shortcut to open your page, or launching it from a browser action button.

Run js-test-driver Eclipse plugin in IE8 document mode when having IE9 installed

I want to use the Eclipse plugin of js test driver to execute my tests in IE. I have IE9 installed but want the tests to run in IE8 document mode because this is what the app we are developing is running in.
So is there any way to start the js-test-driver plugin in IE8 document mode when having IE9 installed? Its possible to switch mode in MS Developer Tools but that is not what I'm looking for.
I've tried to load a script that adds meta tags at start up by adding a script like this in the jsTestDriver.conf file:
...
load:
- js/bootstrap-IE8.js
...
and the code in the bootstrap file:
(function(){
var meta = document.createElement('meta');
meta.setAttribute('http-equiv','X-UA-Compatible');
meta.setAttribute('content','IE=8');
var meta2 = document.createElement('meta');
meta2.setAttribute('Content-Type','X-UA-Compatible');
meta2.setAttribute('content','text/html; charset=utf-8');
var tophead = top.document.getElementsByTagName('head')[0];
var toptitle = tophead.firstChild;
tophead.insertBefore(meta, toptitle);
tophead.insertBefore(meta2, toptitle);
})();
I have tried to find a way to solve this as you describe have not found any way to do this (or JSTestDriver files to modify)
However, this can be done by modifing the registry by setting FEATURE_BROWSER_EMULATION feature that defines the default emulation mode for Internet Explorer to 8888 (0x22B8).
It is descibed at http://msdn.microsoft.com/en-us/library/ee330730%28VS.85%29.aspx#browser_emulation
Note that your browser will use IE8 document mode always.

PhantomJS: page.open() does not respond when running in REPL

I'm trying to run some phantomJS by sending it in via Standard Input, but my webpage open does not respond.
Here is the javascript I'm trying to execute:
require('webpage').create().open('http://google.com', function() { console.log('done'); phantom.exit(); });
Pretty straight forward, right?
Put that in a file.js, and use
phantomjs.exe file.js
and it works, but execute it via REPL
phantomjs.exe
phantomjs> require('webpage').create().open('http://google.com', function() { console.log('done'); phantom.exit(); });
and it never hits the callback. Listening to onResourceRequested shows it is being requested the same, but onResourceReceived never comes back.
This is running on windows 7. Is there anything special I need to do for page.open to work for REPL?
Edit: I should have mentioned, I'm running this from C# in an environment where executing from a file isn't really feasible
Same for me.
After a quick look on git repository, it seems it's a known issue : https://github.com/ariya/phantomjs/issues/10518

Google Extensions API 2

I have a problem. I had a app on the manifest v1.
But now it tells me to change it to v2. But it gives me an error like:
Refused to execute inline script because it violates the following
Content Security Policy directive: "script-src 'self'
chrome-extension-resource:".
I tried to change in the manifest:
"web_accessible_resources": [
"jquery-1.7.1.min.js",
"plugin.js"
]
But in the html code, I have:
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script src="plugin.js"></script>
How do I put it now? Should I delete that? If i delete it won't run! My popup doesn't even opens anymore :|
Hope you understood my problem, thanks
(I'll thank more if someone gave an example of API v2 using javaScript to download :) )
This error usually means that there is some script being executed directly inside your HTML page, not included via an external javascript file.
For example:
<script type="text/javascript">alert('hello');</script> embedded inside your html file is an inline script. The correct way to do it would be
<script type="text/javascript" src="hello.js"></script> .
Your file hello.js would include alert('hello');
I hope this helps.