chromium/third_party/blink/web_tests/http/tests/doc-write-intervention/doc-write-sync-third-party-script-block-effectively-2g.html

<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
    var src = 'http://localhost:8000/loading/resources/js-loaded.js?block-effectively-2g';
    var jsLoaded = false;
    var loadSuccess = false;
    if (window.internals && window.testRunner) {
        internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameIfEffectively2G(true);
        internals.setNetworkConnectionInfoOverride(true, 'cellular3g', 'slow-2g', 2000, 2.0);
        internals.evictAllResources();
        window.addEventListener('beforeunload', function() {
            internals.clearNetworkConnectionInfoOverride();
            internals.setNetworkConnectionInfoOverride(true, 'cellular3g', '4g', 100, 2.0);
            internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameIfEffectively2G(false);
        }, false);
    }
    document.write('<scr' + 'ipt src="' + src + '" onload="loadSuccess=true"></scr' + 'ipt>');
</script>
<script>
    test(function () {
        assert_false(jsLoaded);
        assert_false(loadSuccess);
    }, "Document.written scripts are blocked when effectively 2G");
</script>