1

我有一个测试场景,我需要在登录和退出页面后从窗口对象访问预加载的文件。

线束配置为:

var Harness = Siesta.Harness.Browser.ExtJS;
    Harness.configure({
        preload : [
            'vuxtest.js' 
        ],
        hostPageUrl : '../vux/',
        performSetup : false
    });

测试对象是:

 {  
    url : 'Test.js',
    separateContext : true
 }

预加载的文件 vuxtest.js 设置了 window.vuxtest 对象。

Test.js 的骨架包括:

startTest(function(test) {

   var vuxtestObj = test.global.vuxtest; ...

    vuxtestObj.run(test, 'Icons', function() { 

       test.it('Sign out - Sign in - Test Grid '+ row, function(t) {

           t.chain(
                   //sign out
                   {
                       ...
                   },
                   //sign back in
                   {
                       ...
                   },
                   //call function from vuxtestObj
                   {
                        vuxtestObj.funcA();
                   }
           );
         });
    });
});

此代码在 Chrome 中有效,但在 IE 中无效,因为它在 vuxtestObj.funcA() 上中断并出现错误:无法从已释放的脚本中执行代码。知道我能做些什么来解决这个问题吗?

4

1 回答 1

0

It appears that the callback got unloaded from the object where it is defined after some delay in executing a request. You usually see this message when it happens in IE but other browsers just simply ignore.

Try to wrap the callback in a try-catch block:

try {
   t.chain(
   //sign out
   {
       ...
   },

   //sign back in
   {
       ...
   },

   //call function from vuxtestObj
   {
      vuxtestObj.funcA();
   }
   );
}
catch(err) {

}
于 2015-01-16T19:20:32.723 回答