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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var initialize_BindingsTest = function() { 1 var initialize_BindingsTest = function() {
2 2
3 InspectorTest.preloadModule("sources"); 3 InspectorTest.preloadModule("sources");
4 4
5 InspectorTest.dumpWorkspace = function(previousSnapshot) { 5 InspectorTest.dumpWorkspace = function(previousSnapshot) {
6 var uiSourceCodes = Workspace.workspace.uiSourceCodes().slice(); 6 var uiSourceCodes = Workspace.workspace.uiSourceCodes().slice();
7 var urls = uiSourceCodes.map(code => code.url()); 7 var urls = uiSourceCodes.map(code => code.url());
8 urls = urls.map(url => { 8 urls = urls.map(url => {
9 if (!url.startsWith('debugger://')) 9 if (!url.startsWith('debugger://'))
10 return url; 10 return url;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 evalSource += '//# sourceURL=' + evalSourceURL; 78 evalSource += '//# sourceURL=' + evalSourceURL;
79 return InspectorTest.evaluateInPageAsync(evalSource); 79 return InspectorTest.evaluateInPageAsync(evalSource);
80 80
81 function navigateFrame(frameId, url) { 81 function navigateFrame(frameId, url) {
82 var frame = document.getElementById(frameId); 82 var frame = document.getElementById(frameId);
83 frame.src = url; 83 frame.src = url;
84 return new Promise(x => frame.onload = x); 84 return new Promise(x => frame.onload = x);
85 } 85 }
86 } 86 }
87 87
88 InspectorTest.attachShadowDOM = function(id, templateSelector, evalSourceURL) {
89 var evalSource = `(${createShadowDOM.toString()})('${id}', '${templateSelect or}')`;
90 if (evalSourceURL)
91 evalSource += '//# sourceURL=' + evalSourceURL;
92 return InspectorTest.evaluateInPagePromise(evalSource);
93
94 function createShadowDOM(id, templateSelector) {
95 var shadowHost = document.createElement('div');
96 shadowHost.setAttribute('id', id);
97 let shadowRoot = shadowHost.attachShadow({mode: 'open'});
98 var t = document.querySelector(templateSelector);
99 var instance = t.content.cloneNode(true);
100 shadowRoot.appendChild(instance);
101 document.body.appendChild(shadowHost);
102 }
103 }
104
105 InspectorTest.detachShadowDOM = function(id, evalSourceURL) {
106 var evalSource = `(${removeShadowDOM.toString()})('${id}')`;
107 if (evalSourceURL)
108 evalSource += '//# sourceURL=' + evalSourceURL;
109 return InspectorTest.evaluateInPagePromise(evalSource);
110
111 function removeShadowDOM(id) {
112 document.querySelector('#' + id).remove();
113 }
114 }
115
116 InspectorTest.waitForStyleSheetRemoved = function(urlSuffix) {
117 var fulfill;
118 var promise = new Promise(x => fulfill = x);
119 InspectorTest.cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetRemove d, onStyleSheetRemoved);
120 return promise;
121
122 function onStyleSheetRemoved(event) {
123 var styleSheetHeader = event.data;
124 if (!styleSheetHeader.resourceURL().endsWith(urlSuffix))
125 return;
126 InspectorTest.cssModel.removeEventListener(SDK.CSSModel.Events.StyleShee tRemoved, onStyleSheetRemoved);
127 fulfill();
128 }
129 }
130
88 InspectorTest.addSniffer(Bindings.CompilerScriptMapping.prototype, "_sourceMapAt tachedForTest", onSourceMap, true); 131 InspectorTest.addSniffer(Bindings.CompilerScriptMapping.prototype, "_sourceMapAt tachedForTest", onSourceMap, true);
89 InspectorTest.addSniffer(Bindings.SASSSourceMapping.prototype, "_sourceMapAttach edForTest", onSourceMap, true); 132 InspectorTest.addSniffer(Bindings.SASSSourceMapping.prototype, "_sourceMapAttach edForTest", onSourceMap, true);
90 var sourceMapCallbacks = new Map(); 133 var sourceMapCallbacks = new Map();
91 function onSourceMap(sourceMap) { 134 function onSourceMap(sourceMap) {
92 for (var urlSuffix of sourceMapCallbacks.keys()) { 135 for (var urlSuffix of sourceMapCallbacks.keys()) {
93 if (sourceMap.url().endsWith(urlSuffix)) { 136 if (sourceMap.url().endsWith(urlSuffix)) {
94 var callback = sourceMapCallbacks.get(urlSuffix); 137 var callback = sourceMapCallbacks.get(urlSuffix);
95 callback.call(null); 138 callback.call(null);
96 sourceMapCallbacks.delete(urlSuffix); 139 sourceMapCallbacks.delete(urlSuffix);
97 } 140 }
98 } 141 }
99 } 142 }
100 143
101 InspectorTest.waitForSourceMap = function(sourceMapURLSuffix) { 144 InspectorTest.waitForSourceMap = function(sourceMapURLSuffix) {
102 var fulfill; 145 var fulfill;
103 var promise = new Promise(x => fulfill = x); 146 var promise = new Promise(x => fulfill = x);
104 sourceMapCallbacks.set(sourceMapURLSuffix, fulfill); 147 sourceMapCallbacks.set(sourceMapURLSuffix, fulfill);
105 return promise; 148 return promise;
106 } 149 }
107 150
108 151
109 } 152 }
110 153
OLDNEW
« 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