blob: 45c33e59ece76d98dfbc607ac92ed9701ec91117 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(
`Verify that UISourceCodes are added and removed as shadow dom styles and scripts are added and removed.\n`);
await TestRunner.loadModule('bindings_test_runner');
await TestRunner.loadHTML(`
<template id='template'>
<style>div {
color: blue;
}
/*# sourceURL=sourcemap-style.css */
/*# sourceMappingURL=${TestRunner.url('resources/sourcemap-style.css.map')} */
</style>
<script>window.foo = console.log.bind(console, 'foo');
//# sourceURL=sourcemap-script.js
//# sourceMappingURL=${TestRunner.url('resources/sourcemap-script.js.map')}
</script>
<p>Hi! I'm ShadowDOM v1!</p>
</template>
`);
TestRunner.markStep('dumpInitialWorkspace');
var snapshot = BindingsTestRunner.dumpWorkspace();
TestRunner.markStep('attachShadow1');
await Promise.all([
BindingsTestRunner.attachShadowDOM('shadow1', '#template', '_test_attachShadow1.js'),
BindingsTestRunner.waitForSourceMap('sourcemap-script.js.map'),
BindingsTestRunner.waitForSourceMap('sourcemap-style.css.map'),
]);
snapshot = BindingsTestRunner.dumpWorkspace(snapshot);
TestRunner.markStep('attachShadow2');
await Promise.all([
BindingsTestRunner.attachShadowDOM('shadow2', '#template', '_test_attachShadow2.js'),
BindingsTestRunner.waitForSourceMap('sourcemap-script.js.map'),
BindingsTestRunner.waitForSourceMap('sourcemap-style.css.map'),
]);
snapshot = BindingsTestRunner.dumpWorkspace(snapshot);
TestRunner.markStep('detachShadow1');
await Promise.all([
BindingsTestRunner.detachShadowDOM('shadow1', '_test_detachShadow1.js'),
BindingsTestRunner.waitForStyleSheetRemoved('sourcemap-style.css'),
]);
snapshot = BindingsTestRunner.dumpWorkspace(snapshot);
TestRunner.markStep('detachShadow2');
await Promise.all([
BindingsTestRunner.detachShadowDOM('shadow2', '_test_detachShadow2.js'),
BindingsTestRunner.waitForStyleSheetRemoved('sourcemap-style.css'),
]);
snapshot = BindingsTestRunner.dumpWorkspace(snapshot);
TestRunner.completeTest();
})();