This repository has been archived by the owner on Sep 25, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #453 from turbolinks/async-script-fix
Fix <script async> navigation
- Loading branch information
Showing
7 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { TurbolinksTestCase } from "./helpers/turbolinks_test_case" | ||
|
||
export class AsyncScriptTests extends TurbolinksTestCase { | ||
async setup() { | ||
await this.goToLocation("/fixtures/async_script.html") | ||
} | ||
|
||
async "test does not emit turbolinks:load when loaded asynchronously after DOMContentLoaded"() { | ||
const events = await this.eventLogChannel.read() | ||
this.assert.deepEqual(events, []) | ||
} | ||
|
||
async "test following a link when loaded asynchronously after DOMContentLoaded"() { | ||
this.clickSelector("#async-link") | ||
await this.nextBody | ||
this.assert.equal(await this.visitAction, "advance") | ||
} | ||
} | ||
|
||
AsyncScriptTests.registerSuite() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Turbolinks</title> | ||
<script src="/fixtures/test.js"></script> | ||
<script> | ||
addEventListener("DOMContentLoaded", function() { | ||
setTimeout(function() { | ||
var script = document.createElement("script") | ||
script.src = "/fixtures/turbolinks.js" | ||
script.setAttribute("async", "") | ||
document.head.appendChild(script) | ||
}, 1) | ||
}) | ||
</script> | ||
</head> | ||
<body> | ||
<section> | ||
<h1>Async script</h1> | ||
<p><a href="async_script_2.html" id="async-link">Async script 2</a></p> | ||
</section> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Turbolinks</title> | ||
<script src="/fixtures/test.js"></script> | ||
<script src="/fixtures/turbolinks.js" async></script> | ||
</head> | ||
<body> | ||
<section> | ||
<h1>Async script 2</h1> | ||
</section> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./async_script_tests" | ||
export * from "./navigation_tests" | ||
export * from "./rendering_tests" | ||
export * from "./visit_tests" |