chromium/third_party/blink/web_tests/fast/frames/srcdoc/removing-srcdoc-loads-src.html

<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<body>
<script>
async_test(function(t) {
  var iframe = document.createElement('iframe');
  iframe.src = 'resources/doc.html';
  iframe.srcdoc = 'Set by srcdoc.';
  iframe.onload = t.step_func(srcdocLoaded);
  document.body.appendChild(iframe);

  function srcdocLoaded() {
    assert_equals(
        iframe.contentDocument.documentElement.textContent,
        'Set by srcdoc.',
        'srcdoc should override src when both are present');
    iframe.onload = t.step_func(srcLoaded);
    iframe.removeAttribute('srcdoc');
  }

  function srcLoaded() {
    assert_equals(
        iframe.contentDocument.documentElement.textContent,
        'Hello, world.\n',
        'when srcdoc is removed, src should be loaded');
    t.done();
  }
}, 'Removing an iframe srcdoc attribute should load the src, if set');
</script>