Forum Discussion

sha's avatar
sha
Contributor
11 years ago

JavaScript eval crashes Fifo 31

I am using the following Keyword Testing code in my test:

Run Code Snippet        Aliases.browser.pageMain.contentDocument.Script.eval("localStorage.setItem(\"lastUsedTextProperties\", '{\"fontStyle\":\"400\",\"color\":\"#008800\",\"fontSize\":20,\"fontFamily\":\"Arial\"}');")

to ensure a stable basis for testing.



It used to work, but does not work anymore. When it runs, Firefox crashes with a Mozilla Crash Reporter pop-up. I reckon it is the change from Fifo 30 to 31 that made the difference.



When I run the a "console.log(\"Hullo"\");" through TestComplete it works Ok, and when I run the problematic JavaScript directly in the Firefox (through Firebug Console), it works OK.



Are there better ways to set the localstorage in the browser?



/Søren Harder

QA Engineer, Zmags
  • Hi Søren,



    You can try accessing localStorage through contentDocument.defaultView:



    Aliases.browser.pageMain.contentDocument.defaultView.localStorage.setItem("lastUsedTextProperties", "{'fontStyle':'400','color':'#008800','fontSize':20,'fontFamily':'Arial'}")
  • marin's avatar
    marin
    Frequent Contributor


    Hello Søren,



    it might be that you encountered a problem with contentDocument.script access in Firefox 31.

    I had a very similar problem in one of my tests where there was FF application crash with crash console apearing every time contentDocument.script was invoked from the test methods.



    SmartBear support was helpful and found out that this is a known issue in Firefox and is described here (number 14 - XPCConvert::NativeInterface2JSObject):

    https://crash-stats.mozilla.com/topcrasher/products/Firefox/versions/31.0?days=7



    It was recommended to us to use Firefox 30 for the time being or use different approach until it is fixed.



    Hope this helps,



    Marin

     


  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Søren,



    You can try accessing localStorage through contentDocument.defaultView:



    Aliases.browser.pageMain.contentDocument.defaultView.localStorage.setItem("lastUsedTextProperties", "{'fontStyle':'400','color':'#008800','fontSize':20,'fontFamily':'Arial'}")