diff --git a/lib/capybara-lockstep/helper.js b/lib/capybara-lockstep/helper.js index e820542..7e422a2 100644 --- a/lib/capybara-lockstep/helper.js +++ b/lib/capybara-lockstep/helper.js @@ -177,12 +177,7 @@ window.CapybaraLockstep = (function() { } function isRemoteScript(element) { - if (element.tagName === 'SCRIPT') { - let src = element.getAttribute('src') - let type = element.getAttribute('type') - - return src && (!type || /javascript/i.test(type)) - } + return element.matches('script[src]') && !hasLocalSource(element) } function isRemoteImage(element) { diff --git a/spec/features/synchronization_spec.rb b/spec/features/synchronization_spec.rb index d3e7ebd..023e98c 100644 --- a/spec/features/synchronization_spec.rb +++ b/spec/features/synchronization_spec.rb @@ -255,26 +255,86 @@ end - it 'waits until a dynamically inserted script has loaded' do - App.start_html = <<~HTML - label - HTML + describe 'dynamically loaded scripts' do - wall = Wall.new - App.next_action = -> do - wall.block - content_type 'text/javascript' - 'document.body.style.backgroundColor = "blue"' + it 'waits until a