简体   繁体   English

测试IE8兼容性问题

[英]Testing for IE8 compatibility problems

TL;DR: How can I test for compatibility issues with IE8 on my site? TL; DR:如何在我的网站上测试IE8的兼容性问题?

I wrote up a website for school, and it works on every browser I've tested, except for <=IE8. 我为学校创建了一个网站,该网站可用于我测试过的所有浏览器,但<= IE8除外。

What happens and what I've tried: 发生了什么,我已经尝试过:

  • The site starts to load, then stops, and shows only a blank screen. 该站点开始加载,然后停止,并且仅显示空白屏幕。
  • I figured I was using a method that it doesn't recognize, so I opened the console and refreshed. 我发现我使用的是无法识别的方法,因此我打开了控制台并刷新了。 It gives 0 errors or warnings in the console. 它在控制台中给出0错误或警告。
  • I started the built-in debugger and placed breakpoints at major loading points within the script that handles loading the site. 我启动了内置调试器,并将断点放置在处理站点加载的脚本内的主要加载点上。 Stepping through the code, everything goes as expected, but still only a blank page is shown. 逐步执行代码,一切按预期进行,但仍仅显示空白页。

To test, I'm using IE11's emulation mode, but I experienced the same behavior in a real IE8 browser. 为了进行测试,我使用的是IE11的仿真模式,但是在真正的IE8浏览器中我遇到了相同的行为。

I'm using jQuery 1.11, which supports old versions of IE. 我正在使用jQuery 1.11,它支持IE的旧版本。

I can't really supply code, since there's a lot of it, but I'm passing off anything with sketchy browser support to jQuery, (verified with www.caniuse.com) and again, I'm not receiving any errors indicating that a certain method couldn't be found. 我真的不能提供代码,因为有很多,但是我将任何具有粗略浏览器支持的东西都传递给了jQuery(已通过www.caniuse.com验证),并且再次,我没有收到任何表明找不到某种方法。

From this description, does anyone know what might be going wrong, or how else I could go about diagnosing the problem? 通过此描述,是否有人知道可能出了什么问题,或者我还可以如何诊断问题?

Update: 更新:

I thought everything was peachy while debugging, but I guess that will teach me to debug while at work. 我以为调试时一切都很顺利,但是我想这会教会我在工作时进行调试。

I narrowed it down to the following piece of code: 我将其范围缩小为以下代码:

Resolvable: function() {
    var isResolved = false;
    var onResolve;

    this.resolve = function() {
        isResolved = true;

        if (typeof onResolve !== 'undefined') {
            onResolve();
        }
    };

    this.setOnResolve = function(f) {
        if (isResolved) {
            f();

        } else {
            onResolve = f;
        }
    }

Inside setOnResolve , the else block is entered, the assignment happens, and everything stops loading (the "watch" panel empties out, and any manual watches I've added come up as "not available"). setOnResolve内部,进入else块,进行分配,并且一切都停止加载(“ watch”面板清空,并且我添加的所有手动手表都显示为“ not available”)。

setOnResolve is called here: setOnResolve在这里被调用:

/**
 * Runs each of the {@SuspendedLoader}s, in the order that they're given.
 *
 * @param {SuspendedLoader[]} seqOfSuspLoaders An array of {@link SuspendedLoader}s
 */
runLoadersInOrder: function(seqOfSuspLoaders) {
    if (seqOfSuspLoaders.length < 1) return;

    var currentLoader = seqOfSuspLoaders[0];
    var restLoaders = seqOfSuspLoaders.slice(1);

    var advance = Loaders.PageLoader.runLoadersInOrder;

    var loaderPromise = currentLoader.runLoader();

    if (loaderPromise instanceof Loaders.Helpers.Resolvable) {
        loaderPromise.setOnResolve(function() { //<--- HERE
            advance(restLoaders);
        });
    } else {
        loaderPromise.then(
            function() {
                advance(restLoaders);
            },
            function() {
                throw new Error("Couldn't run loader (" + currentLoader.constructor.name + "): ");
            }
        )
    }

},

I've placed breakpoints on every line of runLoadersInOrder however, and the code never advances past the call to setOnResolve . 但是,我在runLoadersInOrder每一行上都设置了断点,并且代码从不超过对setOnResolve的调用。 I step into setOnResolve , the onResolve assignment happens, then it quits. 我进入setOnResolve ,发生onResolve分配,然后退出。

Further 进一步

I've realized that the issue is actually that runLoadersInOrder is being exited completely instead of recursing. 我意识到问题实际上是runLoadersInOrder完全退出而不是runLoadersInOrder退出。 I'll keep playing with it. 我会继续玩。

I solved it. 我解决了 I'm passing off adding event handlers to jQuery wherever possible, but neglected to handle the case of the jQuery script tag onload event, which obviously never fires in old IE. 我没有在可能的情况下向jQuery添加事件处理程序,但是却忽略了处理jQuery脚本标签onload事件的情况,该事件显然在旧IE中不会触发。 This function was really the problem: 这个功能确实是个问题:

/**
 * Loads a script without using jQuery by inserting a script tag into the page.
 *
 * @param path The folder the scripts are in.
 * @param scriptName The name of the script to load.
 * @returns {Resolvable} A {@link Resolvable} indicating when the script tag is loaded.
 */
Loaders.ScriptLoader.loadJQuery = function(path, scriptName) {
    var firstExistingScript = document.body.getElementsByTagName('script')[0];

    var script = Loaders.ScriptLoader.createScript(path, scriptName);
    document.body.insertBefore(script, firstExistingScript);

    var res = new Loaders.Helpers.Resolvable();
    script.onload = function() {
        $.ajaxSetup({cache: true});

        res.resolve();
    });

    return res;
};

Note how I'm using onload to check for completion, which isn't compatible with old versions of IE. 请注意我如何使用onload来检查是否完成,这与IE的旧版本不兼容。 I changed that part to: 我将该部分更改为:

Loaders.Helpers.attachOnLoad(script, function() {
    $.ajaxSetup({cache: true});

    res.resolve();
});

where attachOnLoad = 其中attachOnLoad =

attachOnLoad: function(element, f) {
if (typeof element.onload === 'undefined') {
        element.onreadystatechange = function() {
            if (element.readyState === 'loaded') {
                f();
            }
        };

    } else {
        element.onload = f;
    }
},

For some reason, the ready state never becomes complete , but does become loaded . 出于某种原因,就绪状态永远不会变得complete ,而是会变为已loaded I'll need to do further testing to ensure it consistently loads. 我需要做进一步的测试,以确保其持续加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM