Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector/bindings/bindings-test.js

Issue 2777633002: DevTools: add bindings tests to fixate shadowDOM behavior. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector/bindings/shadowdom-bindings.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/inspector/bindings/bindings-test.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/bindings/bindings-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector/bindings/bindings-test.js
index e00a11539ae71337b6551990a52e8d8846c50b23..5aa17a07cb64232e7e449620655a49636158f961 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/bindings/bindings-test.js
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/bindings/bindings-test.js
@@ -85,6 +85,49 @@ InspectorTest.navigateFrame = function(frameId, navigateURL, evalSourceURL) {
}
}
+InspectorTest.attachShadowDOM = function(id, templateSelector, evalSourceURL) {
+ var evalSource = `(${createShadowDOM.toString()})('${id}', '${templateSelector}')`;
+ if (evalSourceURL)
+ evalSource += '//# sourceURL=' + evalSourceURL;
+ return InspectorTest.evaluateInPagePromise(evalSource);
+
+ function createShadowDOM(id, templateSelector) {
+ var shadowHost = document.createElement('div');
+ shadowHost.setAttribute('id', id);
+ let shadowRoot = shadowHost.attachShadow({mode: 'open'});
+ var t = document.querySelector(templateSelector);
+ var instance = t.content.cloneNode(true);
+ shadowRoot.appendChild(instance);
+ document.body.appendChild(shadowHost);
+ }
+}
+
+InspectorTest.detachShadowDOM = function(id, evalSourceURL) {
+ var evalSource = `(${removeShadowDOM.toString()})('${id}')`;
+ if (evalSourceURL)
+ evalSource += '//# sourceURL=' + evalSourceURL;
+ return InspectorTest.evaluateInPagePromise(evalSource);
+
+ function removeShadowDOM(id) {
+ document.querySelector('#' + id).remove();
+ }
+}
+
+InspectorTest.waitForStyleSheetRemoved = function(urlSuffix) {
+ var fulfill;
+ var promise = new Promise(x => fulfill = x);
+ InspectorTest.cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetRemoved, onStyleSheetRemoved);
+ return promise;
+
+ function onStyleSheetRemoved(event) {
+ var styleSheetHeader = event.data;
+ if (!styleSheetHeader.resourceURL().endsWith(urlSuffix))
+ return;
+ InspectorTest.cssModel.removeEventListener(SDK.CSSModel.Events.StyleSheetRemoved, onStyleSheetRemoved);
+ fulfill();
+ }
+}
+
InspectorTest.addSniffer(Bindings.CompilerScriptMapping.prototype, "_sourceMapAttachedForTest", onSourceMap, true);
InspectorTest.addSniffer(Bindings.SASSSourceMapping.prototype, "_sourceMapAttachedForTest", onSourceMap, true);
var sourceMapCallbacks = new Map();
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector/bindings/shadowdom-bindings.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698