<commit_before>defineSuite([
        'Core/loadImageFromTypedArray',
        'Core/Resource',
        'ThirdParty/when'
    ], function(
        loadImageFromTypedArray,
        Resource,
        when) {
    'use strict';

    it('can load an image', function() {
        return Resource.fetchArrayBuffer('./Data/Images/Blue10x10.png').then(function(arrayBuffer) {
            var options = {
                uint8Array: new Uint8Array(arrayBuffer),
                format: 'image/png'
            };

            return loadImageFromTypedArray(options).then(function(image) {
                expect(image.width).toEqual(10);
                expect(image.height).toEqual(10);
            });
        });
    });

    it('flips image only when flipY is true', function() {
        var options = {
            uint8Array: new Uint8Array([67, 101, 115, 105, 117, 109]), // This is an invalid PNG.
            format: 'image/png',
            flipY: true
        };
        spyOn(window, 'createImageBitmap').and.returnValue(when.resolve({}));
        var blob = new Blob([options.uint8Array], {
            type : options.format
        });

        return Resource.supportsImageBitmapOptions()
            .then(function(result) {
                if (!result) {
                    return;
                }

                return loadImageFromTypedArray(options)
                    .then(function() {
                        expect(window.createImageBitmap).toHaveBeenCalledWith(blob, {
                            imageOrientation: 'flipY',
                            premultiplyAlpha: 'none'
                        });

                         window.createImageBitmap.calls.reset();
                         options.flipY = false;
                         return loadImageFromTypedArray(options);
                    })
                    .then(function() {
                        expect(window.createImageBitmap).toHaveBeenCalledWith(blob, {
                            imageOrientation: 'none',
                            premultiplyAlpha: 'none'
                        });
                    });
            });
    });

    it('can load an image when ImageBitmap is not supported', function() {
        spyOn(Resource, 'supportsImageBitmapOptions').and.returnValue(when.resolve(false));
        spyOn(window, 'createImageBitmap').and.callThrough();
        return Resource.fetchArrayBuffer('./Data/Images/Blue10x10.png').then(function(arrayBuffer) {
            var options = {
                uint8Array: new Uint8Array(arrayBuffer),
                format: 'image/png'
            };
<commit_msg>Fix ImageBitmap spec on Edge<commit_after>defineSuite([
        'Core/loadImageFromTypedArray',
        'Core/Resource',
        'ThirdParty/when'
    ], function(
        loadImageFromTypedArray,
        Resource,
        when) {
    'use strict';

    var supportsImageBitmapOptions;

    beforeAll(function() {
        return Resource.supportsImageBitmapOptions()
            .then(function(result) {
                supportsImageBitmapOptions = result;
            });
    });

    it('can load an image', function() {
        return Resource.fetchArrayBuffer('./Data/Images/Blue10x10.png').then(function(arrayBuffer) {
            var options = {
                uint8Array: new Uint8Array(arrayBuffer),
                format: 'image/png'
            };

            return loadImageFromTypedArray(options).then(function(image) {
                expect(image.width).toEqual(10);
                expect(image.height).toEqual(10);
            });
        });
    });

    it('flips image only when flipY is true', function() {
        if (!supportsImageBitmapOptions) {
            return;
        }

        var options = {
            uint8Array: new Uint8Array([67, 101, 115, 105, 117, 109]), // This is an invalid PNG.
            format: 'image/png',
            flipY: true
        };
        spyOn(window, 'createImageBitmap').and.returnValue(when.resolve({}));
        var blob = new Blob([options.uint8Array], {
            type : options.format
        });

        return Resource.supportsImageBitmapOptions()
            .then(function(result) {
                if (!result) {
                    return;
                }

                return loadImageFromTypedArray(options)
                    .then(function() {
                        expect(window.createImageBitmap).toHaveBeenCalledWith(blob, {
                            imageOrientation: 'flipY',
                            premultiplyAlpha: 'none'
                        });

                         window.createImageBitmap.calls.reset();
                         options.flipY = false;
                         return loadImageFromTypedArray(options);
                    })
                    .then(function() {
                        expect(window.createImageBitmap).toHaveBeenCalledWith(blob, {
                            imageOrientation: 'none',
                            premultiplyAlpha: 'none'
                        });
                    });
            });
    });

    it('can load an image when ImageBitmap is not supported', function() {
        if (!supportsImageBitmapOptions) {
            return;
        }

        spyOn(Resource, 'supportsImageBitmapOptions').and.returnValue(when.resolve(false));
        spyOn(window, 'createImageBitmap').and.callThrough();
        return Resource.fetchArrayBuffer('./Data/Images/Blue10x10.png').then(function(arrayBuffer) {
            var options = {
                uint8Array: new Uint8Array(arrayBuffer),
                format: 'image/png'
            };

{'fraction_non_alphanumeric': 0.10830517517339498, 'fraction_numerical': 0.012804552729859506, 'mean_word_length': 1.5174574753804835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '919969', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1366, 'n_words': 240}