Exemple #1
0
        public async Task CaptureScriptTagAttributes()
        {
            await DoCapture("", ("src", "some good CDN"), ("integrity", "sha256-bla"));
            await DoCapture("console.log('Foo 2');");

            var content = await DoRender();

            content.Should().Be($"<script integrity=\"sha256-bla\" src=\"some good CDN\"></script>{Environment.NewLine}" +
                                $"<script>console.log('Foo 2');</script>{Environment.NewLine}");
        }
Exemple #2
0
        public async Task NotMergeScriptsReferencesEvenIfMarkedAsMergable()
        {
            const string script1 = "console.log('Foo')";

            await DoCapture(script1);
            await DoCapture(string.Empty, allowMerge : true, attrs : ("src", "https://goodcdn"));

            var content = await DoRender(autoMerge : true);

            content.Should().Be("<script>" +
                                script1 +
                                "</script>" +
                                Environment.NewLine +
                                "<script src=\"https://goodcdn\"></script>" +
                                Environment.NewLine);
        }
Exemple #3
0
        public async Task AutoMergeOnlyScriptsWithContent()
        {
            const string script1 = "console.log('Foo');";
            const string script2 = "console.log('Bar');";

            await DoCapture(script1);
            await DoCapture(script2);
            await DoCapture(string.Empty, attrs : ("src", "https://goodcdn"));

            var content = await DoRender(autoMerge : true);

            content.Should().Be("<script>" +
                                script1 +
                                script2 +
                                "</script>" + Environment.NewLine +
                                "<script src=\"https://goodcdn\"></script>" + Environment.NewLine);
        }
Exemple #4
0
        public async Task DoNotRenderDuplicate()
        {
            var script = "console.log('Foo')";

            await DoCapture(string.Empty, attrs : ("src", "https://goodcdn/foo.js"));
            await DoCapture(script);
            await DoCapture(string.Empty, attrs : ("src", "https://goodcdn/foo.js"));

            var content = await DoRender();

            content.Should().Be("<script src=\"https://goodcdn/foo.js\"></script>" +
                                Environment.NewLine +
                                "<script>" +
                                script +
                                "</script>" +
                                Environment.NewLine);
        }
Exemple #5
0
        public async Task RenderDuplicateIfDuplicateDetectionDisabled()
        {
            var script = "console.log('Foo')";

            await DoCapture(string.Empty, attrs : ("src", "https://goodcdn/foo.js"));
            await DoCapture(script);
            await DoCapture(string.Empty, attrs : ("src", "https://goodcdn/foo.js"));

            var content = await DoRender(noDuplicateSource : "false");

            content.Should().Be("<script src=\"https://goodcdn/foo.js\"></script>" +
                                Environment.NewLine +
                                "<script>" +
                                script +
                                "</script>" +
                                Environment.NewLine +
                                "<script src=\"https://goodcdn/foo.js\"></script>" +
                                Environment.NewLine);
        }