mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-17 17:38:10 +00:00
Merge pull request #1079 from lightpanda-io/dynamic_import_caching
Dynamic import caching
This commit is contained in:
19
src/tests/html/script/dynamic_import.html
Normal file
19
src/tests/html/script/dynamic_import.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<script src="../../testing.js"></script>
|
||||
|
||||
<script id=dynamic_import type=module>
|
||||
const promise1 = new Promise((resolve) => {
|
||||
Promise.all([
|
||||
import('./import.js'),
|
||||
import('./import.js'),
|
||||
import('./import2.js'),
|
||||
]).then(resolve);
|
||||
});
|
||||
|
||||
testing.async(promise1, (res) => {
|
||||
testing.expectEqual('hello', res[0].greeting);
|
||||
testing.expectEqual('hello', res[1].greeting);
|
||||
testing.expectEqual('world', res[2].greeting);
|
||||
})
|
||||
</script>
|
||||
15
src/tests/html/script/import.html
Normal file
15
src/tests/html/script/import.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<script src="../../testing.js"></script>
|
||||
|
||||
<script id=import type=module>
|
||||
import * as im from './import.js';
|
||||
testing.expectEqual('hello', im.greeting);
|
||||
</script>
|
||||
|
||||
<script id=cached type=module>
|
||||
// hopefully cached, who knows, no real way to assert this
|
||||
// but at least it works.
|
||||
import * as im from './import.js';
|
||||
testing.expectEqual('hello', im.greeting);
|
||||
</script>
|
||||
2
src/tests/html/script/import.js
Normal file
2
src/tests/html/script/import.js
Normal file
@@ -0,0 +1,2 @@
|
||||
let greeting = 'hello';
|
||||
export {greeting as 'greeting'};
|
||||
2
src/tests/html/script/import2.js
Normal file
2
src/tests/html/script/import2.js
Normal file
@@ -0,0 +1,2 @@
|
||||
let greeting = 'world';
|
||||
export {greeting as 'greeting'};
|
||||
@@ -93,7 +93,7 @@
|
||||
}
|
||||
|
||||
async function async(promise, cb) {
|
||||
const script_id = document.currentScript.id;
|
||||
const script_id = document.currentScript ? document.currentScript.id : '<script id is unavailable in browsers>';
|
||||
const stack = new Error().stack;
|
||||
this._captured = {script_id: script_id, stack: stack};
|
||||
const value = await promise;
|
||||
|
||||
Reference in New Issue
Block a user