用于模拟Internet Explorer JavaScript环境的JavaScript库? [英] JavaScript library to simulate Internet Explorer JavaScript environment?

查看:104
本文介绍了用于模拟Internet Explorer JavaScript环境的JavaScript库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与用于模拟Internet Explorer的 JS库不重复?关于模拟Internet Explorer的CSS支持的问题;这是关于JavaScript函数的。



是否存在可以模拟Internet Explorer等环境的JavaScript库,而JavaScript函数是什么?



基本上,它会删除/覆盖旧版本IE不支持的功能(如indexOf等),或至少强制对它们的任何调用以某种方式被忽略。 / p>

实际上,我正在寻找的东西几乎与 Underscore.js ,理论上甚至可以用来测试(在非IE浏览器中)Underscore.js正在做它想要做的事情。



是模拟环境所需的努力量,以至于我自己可以快速完成这项工作?如果是这样,怎么样?






我想象的用例:



使用此脚本在 Phantom.js 的WebKit浏览器中模拟IE7环境以实现自动化(由Jenkins提供)使用Jasmine / QUnit / etc进行JavaScript单元测试(未定)。

解决方案

我建议反对,因为你' d测试你支持这种模拟的程度,而不是IE7本身。 IE7引擎大多符合标准,除了一些怪癖(比如悬挂逗号的糟糕反应),当然还有最新标准的环境缺失。大多数这些怪癖要么与其他浏览器一致,要么在没有用JS编写完整的JS引擎的情况下不能轻易模拟。您可能需要查阅清单在ES维基上获取更多详细信息(并注意FF / Opera / Safari:相同部分,您可能不希望考虑IE与ES的差异)。



你最好的选择是使用一个真正的IE7,BTW,非常好的自动化界面几乎适用于所有测试,或者至少是最新的IE版本兼容模式已开启。


This is not a duplicate of the JS library to simulate Internet Explorer? question about simulating Internet Explorer's CSS support; this is about JavaScript functions.

Does a JavaScript library exist which can simulate an environment like Internet Explorer's, whereas JavaScript functions are concerned?

Basically, it would remove/overwrite the functions not supported by older versions of IE (like indexOf, etc.) or at least force any call to them to be ignored somehow.

Effectively, what I'm looking for is something almost like the opposite of Underscore.js and which theoretically could even be used to test (in non-IE browsers) that Underscore.js is doing what it's meant to do.

Or is the amount of effort needed to simulate the environment so small that I can do it quickly myself? If so, how?


The use case I'm imagining:

Using this script to simulate an IE7 environment in Phantom.js's WebKit browser for automated (by Jenkins) JavaScript unit-testing with Jasmine / QUnit / etc (undecided).

解决方案

I'd advise against that, because you'd be testing how well you support this simulation then, not IE7 itself. IE7 engine is mostly compliant with standards, save for a few quirks (like bad reaction at dangling commas) and of course, missing environment from most recent standards. Most of those quirks are either in line with other browsers or cannot be easily emulated without writing complete JS engine in JS. You may want to consult a list on ES wiki for more details (and note "FF/Opera/Safari: same" sections, where you will likely want not to account for IE's discrepancies with ES).

Your best bet would be to either use a real IE7, that, BTW, have very good automation interface for pretty much any testing, or, at very least, more recent IE version with compatibility mode turned on.

这篇关于用于模拟Internet Explorer JavaScript环境的JavaScript库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆