From: Ahmed A. <asa...@ya...> - 2013-11-13 07:37:52
|
Hi all, This is an example of isolating a root cause, it is captured during handling "https://www.google.com/voice/". IE8 doesn't trigger 'in message!', while HtmlUnit does, mostly because of targetOrigin in postMessage() parameter. To be fixed soon. -------------------- 1.html <html><head><script> function something() { alert('in message!'); } function test() { window.attachEvent('onmessage', something); var iframe = document.createElement('iframe'); iframe.src = '2.html'; document.body.appendChild(iframe); } </script> </head> <body onload='test()'></body> </html> ----------------- 2.html <html><head> <script> window.parent.postMessage('hi', 'https://accounts.google.com'); </script> </head> </html> ________________________________ From: Marcus Halverstrom <dop...@ho...> To: "htm...@li..." <htm...@li...> Sent: Tuesday, November 12, 2013 1:51 PM Subject: [Htmlunit-user] Simple App to Read Google Voice I want to make a simple app to read my google voice page and log the most recent calls I started with loading the login page HtmlPage login = webClient.getPage("https://www.google.com/voice/"); I tried this using BrowserVersion.CHROME, and BrowserVersion.FIREFOX_17. I received the following error (truncated for convenience). ---------- Exception class=[net.sourceforge.htmlunit.corejs.javascript.WrappedException] com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call method "toLowerCase" of undefined (script in https://accounts.google.com/ServiceLogin?service=grandcentral&passive=1209600&continue=https%3A%2F%2Fwww.google.com%2Fvoice%2F&followup=https%3A%2F%2Fwww.google.com%2Fvoice%2F<mpl=open from (1158, 11) to (1170, 10)#1167) ------------ After looking around, I tried webClient.getOptions().setJavaScriptEnabled(false); HtmlPage login = webClient.getPage("https://www.google.com/voice/"); followed by some code to enter my email and password and submit. This worked (I could see my google voice phone number in the dom). Then I wanted to read my most recent calls. So I did the following webClient.getOptions().setJavaScriptEnabled(true); //not sure if this is necessary it was just tried in my latest iteration webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); HtmlPage history = webClient.getPage("https://www.google.com/voice/#history"); //not sure if this is necessary it was just tried in my latest iteration history.refresh(); //this is the element that contains the recent calls DomElement e = history.getElementById("gc-view-main"); //BUT IT'S EMPTY System.out.println(e.asXml()); //printed: //--------- //<div id="gc-view-main" class="gc-inbox-view-main"> //</div> //----------- When accessed via my browser this element is NOT empty. I don't know what's going on. In addition when loading, I get the tons of errors below. I don't know if these are to be expected or not. Nov 12, 2013 3:25:03 AM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'text/javascript'. Nov 12, 2013 3:25:03 AM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'text/javascript'. Nov 12, 2013 3:25:15 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error WARNING: CSS error: 'https://www.google.com/voice/resources/3437195615-gc-prod.css' [1:19330] Error in expression. (Invalid token "#4d90fe". Was expecting one of: <S>, <NUMBER>, <IDENT>, <STRING>, <PLUS>, <COMMA>, <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <PERCENTAGE>, <URI>, "-", "=", ")".) |