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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/inspector/persistence/automapping-test.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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
OLDNEW
1 var initialize_AutomappingTest = function() { 1 var initialize_AutomappingTest = function() {
2 2
3 InspectorTest.addFiles = function(testFileSystem, files) 3 InspectorTest.addFiles = function(testFileSystem, files)
4 { 4 {
5 for (var filePath in files) { 5 for (var filePath in files) {
6 var file = files[filePath]; 6 var file = files[filePath];
7 testFileSystem.addFile(filePath, file.content, file.time ? file.time.get Time() : 0); 7 testFileSystem.addFile(filePath, file.content, file.time ? file.time.get Time() : 0);
8 } 8 }
9 } 9 }
10 10
11 var timeOverrides; 11 var timeOverrides;
12 var originalRequestMetadata; 12 var originalRequestMetadata;
13 InspectorTest.overrideNetworkModificationTime = function(urlToTime) 13 InspectorTest.overrideNetworkModificationTime = function(urlToTime)
14 { 14 {
15 if (!timeOverrides) { 15 if (!timeOverrides) {
16 timeOverrides = new Map(); 16 timeOverrides = new Map();
17 originalRequestMetadata = InspectorTest.override(WebInspector.ContentPro viderBasedProject.prototype, "requestMetadata", overrideTime, true); 17 originalRequestMetadata = InspectorTest.override(Bindings.ContentProvide rBasedProject.prototype, "requestMetadata", overrideTime, true);
18 } 18 }
19 for (var url in urlToTime) 19 for (var url in urlToTime)
20 timeOverrides.set(url, urlToTime[url]); 20 timeOverrides.set(url, urlToTime[url]);
21 21
22 function overrideTime(uiSourceCode) 22 function overrideTime(uiSourceCode)
23 { 23 {
24 if (!timeOverrides.has(uiSourceCode.url())) 24 if (!timeOverrides.has(uiSourceCode.url()))
25 return originalRequestMetadata.call(this, uiSourceCode); 25 return originalRequestMetadata.call(this, uiSourceCode);
26 var override = timeOverrides.get(uiSourceCode.url()); 26 var override = timeOverrides.get(uiSourceCode.url());
27 return originalRequestMetadata.call(this, uiSourceCode).then(onOriginalM etadata.bind(null, override)); 27 return originalRequestMetadata.call(this, uiSourceCode).then(onOriginalM etadata.bind(null, override));
28 } 28 }
29 29
30 function onOriginalMetadata(timeOverride, metadata) 30 function onOriginalMetadata(timeOverride, metadata)
31 { 31 {
32 if (!timeOverride && !metadata) 32 if (!timeOverride && !metadata)
33 return null; 33 return null;
34 return new WebInspector.UISourceCodeMetadata(timeOverride, metadata ? me tadata.contentSize : null); 34 return new Workspace.UISourceCodeMetadata(timeOverride, metadata ? metad ata.contentSize : null);
35 } 35 }
36 } 36 }
37 37
38 InspectorTest.AutomappingTest = function(workspace) 38 InspectorTest.AutomappingTest = function(workspace)
39 { 39 {
40 this._workspace = workspace; 40 this._workspace = workspace;
41 this._networkProject = new WebInspector.ContentProviderBasedProject(this._wo rkspace, "AUTOMAPPING", WebInspector.projectTypes.Network, "simple website"); 41 this._networkProject = new Bindings.ContentProviderBasedProject(this._worksp ace, "AUTOMAPPING", Workspace.projectTypes.Network, "simple website");
42 if (workspace !== WebInspector.workspace) 42 if (workspace !== Workspace.workspace)
43 new WebInspector.FileSystemWorkspaceBinding(WebInspector.isolatedFileSys temManager, this._workspace); 43 new Bindings.FileSystemWorkspaceBinding(Workspace.isolatedFileSystemMana ger, this._workspace);
44 this._failedBindingsCount = 0; 44 this._failedBindingsCount = 0;
45 this._automapping = new WebInspector.Automapping(this._workspace, this._onBi ndingAdded.bind(this), this._onBindingRemoved.bind(this)); 45 this._automapping = new Persistence.Automapping(this._workspace, this._onBin dingAdded.bind(this), this._onBindingRemoved.bind(this));
46 InspectorTest.addSniffer(this._automapping, "_onBindingFailedForTest", this. _onBindingFailed.bind(this), true); 46 InspectorTest.addSniffer(this._automapping, "_onBindingFailedForTest", this. _onBindingFailed.bind(this), true);
47 InspectorTest.addSniffer(this._automapping, "_onSweepHappenedForTest", this. _onSweepHappened.bind(this), true); 47 InspectorTest.addSniffer(this._automapping, "_onSweepHappenedForTest", this. _onSweepHappened.bind(this), true);
48 } 48 }
49 49
50 InspectorTest.AutomappingTest.prototype = { 50 InspectorTest.AutomappingTest.prototype = {
51 removeResources: function(urls) 51 removeResources: function(urls)
52 { 52 {
53 for (var url of urls) 53 for (var url of urls)
54 this._networkProject.removeFile(url); 54 this._networkProject.removeFile(url);
55 }, 55 },
56 56
57 addNetworkResources: function(assets) 57 addNetworkResources: function(assets)
58 { 58 {
59 for (var url in assets) { 59 for (var url in assets) {
60 var asset = assets[url]; 60 var asset = assets[url];
61 var contentType = asset.contentType || WebInspector.resourceTypes.Sc ript; 61 var contentType = asset.contentType || Common.resourceTypes.Script;
62 var contentProvider = new WebInspector.StaticContentProvider(url, co ntentType, Promise.resolve(asset.content)); 62 var contentProvider = new Common.StaticContentProvider(url, contentT ype, Promise.resolve(asset.content));
63 var metadata = typeof asset.content === "string" || asset.time ? new WebInspector.UISourceCodeMetadata(asset.time, asset.content.length) : null; 63 var metadata = typeof asset.content === "string" || asset.time ? new Workspace.UISourceCodeMetadata(asset.time, asset.content.length) : null;
64 var uiSourceCode = this._networkProject.createUISourceCode(url, cont entType); 64 var uiSourceCode = this._networkProject.createUISourceCode(url, cont entType);
65 this._networkProject.addUISourceCodeWithProvider(uiSourceCode, conte ntProvider, metadata); 65 this._networkProject.addUISourceCodeWithProvider(uiSourceCode, conte ntProvider, metadata);
66 } 66 }
67 }, 67 },
68 68
69 waitUntilMappingIsStabilized: function(callback) 69 waitUntilMappingIsStabilized: function(callback)
70 { 70 {
71 this._stabilizedCallback = callback; 71 this._stabilizedCallback = callback;
72 this._checkStabilized(); 72 this._checkStabilized();
73 }, 73 },
(...skipping 19 matching lines...) Expand all
93 _onBindingRemoved: function(binding) 93 _onBindingRemoved: function(binding)
94 { 94 {
95 InspectorTest.addResult("Binding removed: " + binding); 95 InspectorTest.addResult("Binding removed: " + binding);
96 this._checkStabilized(); 96 this._checkStabilized();
97 }, 97 },
98 98
99 _checkStabilized: function() 99 _checkStabilized: function()
100 { 100 {
101 if (!this._stabilizedCallback || this._automapping._sweepThrottler._proc ess) 101 if (!this._stabilizedCallback || this._automapping._sweepThrottler._proc ess)
102 return; 102 return;
103 var networkUISourceCodes = this._workspace.uiSourceCodesForProjectType(W ebInspector.projectTypes.Network); 103 var networkUISourceCodes = this._workspace.uiSourceCodesForProjectType(W orkspace.projectTypes.Network);
104 var stabilized = this._failedBindingsCount + this._automapping._bindings .size === networkUISourceCodes.length; 104 var stabilized = this._failedBindingsCount + this._automapping._bindings .size === networkUISourceCodes.length;
105 if (stabilized) { 105 if (stabilized) {
106 InspectorTest.addResult("Mapping has stabilized."); 106 InspectorTest.addResult("Mapping has stabilized.");
107 var callback = this._stabilizedCallback; 107 var callback = this._stabilizedCallback;
108 delete this._stabilizedCallback; 108 delete this._stabilizedCallback;
109 callback.call(null); 109 callback.call(null);
110 } 110 }
111 } 111 }
112 } 112 }
113 113
114 } 114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698