From: Teryl T. <ter...@gm...> - 2015-06-12 19:26:06
|
Hi everyone, Thanks Ahmed for the help on the last question! I'm having a small issue with swfobject.js. For those not familiar with the script, it's an opensource script that allows for a simple loading of flash files in a website, by creating the object tags... For example: ------------------------------------------------------------------------------------------------------------------------------- <html> <head> <script type="text/javascript" src=" http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> <script type="text/javascript"> var flashvars = {}; var params = {}; params.play = "true"; params.wmode = "transparent"; params.allowscriptaccess = "always"; var attributes = {}; swfobject.embedSWF("/temp1.swf", "test", "800", "600", "9.0.0", false, flashvars, params, attributes); </script> </head> <body> <div id="test"></div> </body> </html> -------------------------------------------------------------------------------------------------------------------------------- I'm simulating an IE 11 browser: HashMap<String, String> activeXObjects = new HashMap<String,String>(); activeXObjects.put("ShockwaveFlash.ShockwaveFlash", "ShockwaveObject"); BrowserVersion browser = BrowserVersion.INTERNET_EXPLORER_11; try (final WebClient webClient = new WebClient(browser, proxyHost_, proxyPort_)) { webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getOptions().setAppletEnabled(true); webClient.getOptions().setCssEnabled(true); webClient.setJavaScriptErrorListener(new JSErrorListener()); webClient.getOptions().setJavaScriptEnabled(true); webClient.setAlertHandler(new DebugHandler()); webClient.setScriptPreProcessor(new IEConditionalCompilationScriptPreProcessor()); JavaScriptEngine js = webClient.getJavaScriptEngine(); webClient.setActiveXObjectMap(activeXObjects); } -------------------------------------------------------------------------------------------------------------------------------- When I run it, the outputted html doesn't contain the object tags. After debugging the swfobject.js file, I came to the issue being this line of code: if (typeof O.ActiveXObject != D) { ..... } Where O = window, and D = undefined.... if I print out typeof O.ActiveXObject, then sure enough I get "undefined". But if I print simply O.ActiveXObject, I get something to the effect of function ActiveXObject() { [native] } I'm trying to debug this but I'm not sure how the typeof function works in the JavaScriptEngine. Is there a function or HTMLUnit class that someone could point me too that I could debug to see what's happening? I've been playing around with com/gargoylesoftware/htmlunit/javascript/SimpleScriptable.java but it's not giving me what I expected. If someone wants a small working example, I can provide one. I'm happy to debug it myself, just not sure what source code to look at. Best, Teryl |