| OLD | NEW |
| 1 var framesCount = 0; | 1 var framesCount = 0; |
| 2 | 2 |
| 3 function createAndNavigateIFrame(url) | 3 function createAndNavigateIFrame(url) |
| 4 { | 4 { |
| 5 var iframe = document.createElement("iframe"); | 5 var iframe = document.createElement("iframe"); |
| 6 iframe.src = url; | 6 iframe.src = url; |
| 7 iframe.name = "frame" + ++framesCount; | 7 iframe.name = "frame" + ++framesCount; |
| 8 iframe.id = iframe.name; | 8 iframe.id = iframe.name; |
| 9 document.body.appendChild(iframe); | 9 document.body.appendChild(iframe); |
| 10 } | 10 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 function swapFrameCache(name) | 24 function swapFrameCache(name) |
| 25 { | 25 { |
| 26 var iframe = document.querySelector("#" + name); | 26 var iframe = document.querySelector("#" + name); |
| 27 iframe.contentWindow.applicationCache.swapCache(); | 27 iframe.contentWindow.applicationCache.swapCache(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 var initialize_ApplicationCacheTest = function() { | 30 var initialize_ApplicationCacheTest = function() { |
| 31 | 31 |
| 32 InspectorTest.createAndNavigateIFrame = function(url, callback) | 32 InspectorTest.createAndNavigateIFrame = function(url, callback) |
| 33 { | 33 { |
| 34 InspectorTest.addSniffer(WebInspector.ResourceTreeModel.prototype, "_frameNa
vigated", frameNavigated); | 34 InspectorTest.addSniffer(SDK.ResourceTreeModel.prototype, "_frameNavigated",
frameNavigated); |
| 35 InspectorTest.evaluateInPage("createAndNavigateIFrame(unescape('" + escape(u
rl) + "'))"); | 35 InspectorTest.evaluateInPage("createAndNavigateIFrame(unescape('" + escape(u
rl) + "'))"); |
| 36 | 36 |
| 37 function frameNavigated(frame) | 37 function frameNavigated(frame) |
| 38 { | 38 { |
| 39 callback(frame.id); | 39 callback(frame.id); |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 InspectorTest.navigateIFrame = function(frameId, url, callback) | 43 InspectorTest.navigateIFrame = function(frameId, url, callback) |
| 44 { | 44 { |
| 45 var frame = InspectorTest.resourceTreeModel.frameForId(frameId) | 45 var frame = InspectorTest.resourceTreeModel.frameForId(frameId) |
| 46 InspectorTest.evaluateInPage("navigateIFrame(unescape('" + escape(frame.name
) +"'), unescape('" + escape(url) + "'))"); | 46 InspectorTest.evaluateInPage("navigateIFrame(unescape('" + escape(frame.name
) +"'), unescape('" + escape(url) + "'))"); |
| 47 InspectorTest.addSniffer(WebInspector.ResourceTreeModel.prototype, "_frameNa
vigated", frameNavigated); | 47 InspectorTest.addSniffer(SDK.ResourceTreeModel.prototype, "_frameNavigated",
frameNavigated); |
| 48 | 48 |
| 49 function frameNavigated(frame) | 49 function frameNavigated(frame) |
| 50 { | 50 { |
| 51 callback(frame.id); | 51 callback(frame.id); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 InspectorTest.removeIFrame = function(frameId, callback) | 55 InspectorTest.removeIFrame = function(frameId, callback) |
| 56 { | 56 { |
| 57 var frame = InspectorTest.resourceTreeModel.frameForId(frameId) | 57 var frame = InspectorTest.resourceTreeModel.frameForId(frameId) |
| 58 InspectorTest.evaluateInPage("removeIFrame(unescape('" + escape(frame.name)
+"'))"); | 58 InspectorTest.evaluateInPage("removeIFrame(unescape('" + escape(frame.name)
+"'))"); |
| 59 InspectorTest.addSniffer(WebInspector.ResourceTreeModel.prototype, "_frameDe
tached", frameDetached); | 59 InspectorTest.addSniffer(SDK.ResourceTreeModel.prototype, "_frameDetached",
frameDetached); |
| 60 | 60 |
| 61 function frameDetached(frame) | 61 function frameDetached(frame) |
| 62 { | 62 { |
| 63 callback(frame.id); | 63 callback(frame.id); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 InspectorTest.swapFrameCache = function(frameId) | 67 InspectorTest.swapFrameCache = function(frameId) |
| 68 { | 68 { |
| 69 var frame = InspectorTest.resourceTreeModel.frameForId(frameId); | 69 var frame = InspectorTest.resourceTreeModel.frameForId(frameId); |
| 70 InspectorTest.evaluateInPage("swapFrameCache(unescape('" + escape(frame.name
) +"'))"); | 70 InspectorTest.evaluateInPage("swapFrameCache(unescape('" + escape(frame.name
) +"'))"); |
| 71 } | 71 } |
| 72 | 72 |
| 73 | 73 |
| 74 InspectorTest.dumpApplicationCache = function() | 74 InspectorTest.dumpApplicationCache = function() |
| 75 { | 75 { |
| 76 InspectorTest.dumpApplicationCacheTree(); | 76 InspectorTest.dumpApplicationCacheTree(); |
| 77 InspectorTest.dumpApplicationCacheModel(); | 77 InspectorTest.dumpApplicationCacheModel(); |
| 78 InspectorTest.addResult(""); | 78 InspectorTest.addResult(""); |
| 79 } | 79 } |
| 80 | 80 |
| 81 InspectorTest.dumpApplicationCacheTree = function() | 81 InspectorTest.dumpApplicationCacheTree = function() |
| 82 { | 82 { |
| 83 InspectorTest.addResult("Dumping application cache tree:"); | 83 InspectorTest.addResult("Dumping application cache tree:"); |
| 84 var applicationCacheTreeElement = WebInspector.panels.resources.applicationC
acheListTreeElement; | 84 var applicationCacheTreeElement = UI.panels.resources.applicationCacheListTr
eeElement; |
| 85 if (!applicationCacheTreeElement.childCount()) { | 85 if (!applicationCacheTreeElement.childCount()) { |
| 86 InspectorTest.addResult(" (empty)"); | 86 InspectorTest.addResult(" (empty)"); |
| 87 return; | 87 return; |
| 88 } | 88 } |
| 89 for (var i = 0; i < applicationCacheTreeElement.childCount(); ++i) { | 89 for (var i = 0; i < applicationCacheTreeElement.childCount(); ++i) { |
| 90 var manifestTreeElement = applicationCacheTreeElement.childAt(i); | 90 var manifestTreeElement = applicationCacheTreeElement.childAt(i); |
| 91 InspectorTest.addResult(" Manifest URL: " + manifestTreeElement.manif
estURL); | 91 InspectorTest.addResult(" Manifest URL: " + manifestTreeElement.manif
estURL); |
| 92 if (!manifestTreeElement.childCount()) { | 92 if (!manifestTreeElement.childCount()) { |
| 93 InspectorTest.addResult(" (no frames)"); | 93 InspectorTest.addResult(" (no frames)"); |
| 94 continue; | 94 continue; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 120 statusInformation[applicationCache.CHECKING] = "CHECKING"; | 120 statusInformation[applicationCache.CHECKING] = "CHECKING"; |
| 121 statusInformation[applicationCache.DOWNLOADING] = "DOWNLOADING"; | 121 statusInformation[applicationCache.DOWNLOADING] = "DOWNLOADING"; |
| 122 statusInformation[applicationCache.UPDATEREADY] = "UPDATEREADY"; | 122 statusInformation[applicationCache.UPDATEREADY] = "UPDATEREADY"; |
| 123 statusInformation[applicationCache.OBSOLETE] = "OBSOLETE"; | 123 statusInformation[applicationCache.OBSOLETE] = "OBSOLETE"; |
| 124 return statusInformation[status] || statusInformation[applicationCache.UNCAC
HED]; | 124 return statusInformation[status] || statusInformation[applicationCache.UNCAC
HED]; |
| 125 } | 125 } |
| 126 | 126 |
| 127 InspectorTest.dumpApplicationCacheModel = function() | 127 InspectorTest.dumpApplicationCacheModel = function() |
| 128 { | 128 { |
| 129 InspectorTest.addResult("Dumping application cache model:"); | 129 InspectorTest.addResult("Dumping application cache model:"); |
| 130 var model = WebInspector.panels.resources._applicationCacheModel; | 130 var model = UI.panels.resources._applicationCacheModel; |
| 131 | 131 |
| 132 var frameIds = []; | 132 var frameIds = []; |
| 133 for (var frameId in model._manifestURLsByFrame) | 133 for (var frameId in model._manifestURLsByFrame) |
| 134 frameIds.push(frameId); | 134 frameIds.push(frameId); |
| 135 | 135 |
| 136 function compareFunc(a, b) { | 136 function compareFunc(a, b) { |
| 137 return InspectorTest.frameIdToString(a).localeCompare(InspectorTest.fram
eIdToString(b)); | 137 return InspectorTest.frameIdToString(a).localeCompare(InspectorTest.fram
eIdToString(b)); |
| 138 } | 138 } |
| 139 frameIds.sort(compareFunc); | 139 frameIds.sort(compareFunc); |
| 140 | 140 |
| 141 if (!frameIds.length) { | 141 if (!frameIds.length) { |
| 142 InspectorTest.addResult(" (empty)"); | 142 InspectorTest.addResult(" (empty)"); |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 for (var i = 0; i < frameIds.length; ++i) { | 145 for (var i = 0; i < frameIds.length; ++i) { |
| 146 var frameId = frameIds[i]; | 146 var frameId = frameIds[i]; |
| 147 var manifestURL = model.frameManifestURL(frameId); | 147 var manifestURL = model.frameManifestURL(frameId); |
| 148 var status = model.frameManifestStatus(frameId); | 148 var status = model.frameManifestStatus(frameId); |
| 149 InspectorTest.addResult(" Frame: " + InspectorTest.frameIdToString(fr
ameId)); | 149 InspectorTest.addResult(" Frame: " + InspectorTest.frameIdToString(fr
ameId)); |
| 150 InspectorTest.addResult(" manifest url: " + manifestURL); | 150 InspectorTest.addResult(" manifest url: " + manifestURL); |
| 151 InspectorTest.addResult(" status: " + InspectorTest.applica
tionCacheStatusToString(status)); | 151 InspectorTest.addResult(" status: " + InspectorTest.applica
tionCacheStatusToString(status)); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 InspectorTest.waitForFrameManifestURLAndStatus = function(frameId, manifestURL,
status, callback) | 155 InspectorTest.waitForFrameManifestURLAndStatus = function(frameId, manifestURL,
status, callback) |
| 156 { | 156 { |
| 157 var frameManifestStatus = WebInspector.panels.resources._applicationCacheMod
el.frameManifestStatus(frameId); | 157 var frameManifestStatus = UI.panels.resources._applicationCacheModel.frameMa
nifestStatus(frameId); |
| 158 var frameManifestURL = WebInspector.panels.resources._applicationCacheModel.
frameManifestURL(frameId); | 158 var frameManifestURL = UI.panels.resources._applicationCacheModel.frameManif
estURL(frameId); |
| 159 if (frameManifestStatus === status && frameManifestURL.indexOf(manifestURL)
!== -1) { | 159 if (frameManifestStatus === status && frameManifestURL.indexOf(manifestURL)
!== -1) { |
| 160 callback(); | 160 callback(); |
| 161 return; | 161 return; |
| 162 } | 162 } |
| 163 | 163 |
| 164 var handler = InspectorTest.waitForFrameManifestURLAndStatus.bind(this, fram
eId, manifestURL, status, callback); | 164 var handler = InspectorTest.waitForFrameManifestURLAndStatus.bind(this, fram
eId, manifestURL, status, callback); |
| 165 InspectorTest.addSniffer(WebInspector.ApplicationCacheModel.prototype, "_fra
meManifestUpdated", handler); | 165 InspectorTest.addSniffer(SDK.ApplicationCacheModel.prototype, "_frameManifes
tUpdated", handler); |
| 166 } | 166 } |
| 167 | 167 |
| 168 InspectorTest.startApplicationCacheStatusesRecording = function() | 168 InspectorTest.startApplicationCacheStatusesRecording = function() |
| 169 { | 169 { |
| 170 if (InspectorTest.applicationCacheStatusesRecords) { | 170 if (InspectorTest.applicationCacheStatusesRecords) { |
| 171 InspectorTest.applicationCacheStatusesRecords = {}; | 171 InspectorTest.applicationCacheStatusesRecords = {}; |
| 172 return; | 172 return; |
| 173 } | 173 } |
| 174 | 174 |
| 175 InspectorTest.applicationCacheStatusesRecords = {}; | 175 InspectorTest.applicationCacheStatusesRecords = {}; |
| 176 function addRecord(frameId, manifestURL, status) { | 176 function addRecord(frameId, manifestURL, status) { |
| 177 var record = {}; | 177 var record = {}; |
| 178 record.manifestURL = manifestURL; | 178 record.manifestURL = manifestURL; |
| 179 record.status = status; | 179 record.status = status; |
| 180 if (!InspectorTest.applicationCacheStatusesRecords[frameId]) | 180 if (!InspectorTest.applicationCacheStatusesRecords[frameId]) |
| 181 InspectorTest.applicationCacheStatusesRecords[frameId] = []; | 181 InspectorTest.applicationCacheStatusesRecords[frameId] = []; |
| 182 InspectorTest.applicationCacheStatusesRecords[frameId].push(record); | 182 InspectorTest.applicationCacheStatusesRecords[frameId].push(record); |
| 183 | 183 |
| 184 if (InspectorTest.awaitedFrameStatusEventsCount && InspectorTest.awaited
FrameStatusEventsCount[frameId]) { | 184 if (InspectorTest.awaitedFrameStatusEventsCount && InspectorTest.awaited
FrameStatusEventsCount[frameId]) { |
| 185 InspectorTest.awaitedFrameStatusEventsCount[frameId].count--; | 185 InspectorTest.awaitedFrameStatusEventsCount[frameId].count--; |
| 186 if (!InspectorTest.awaitedFrameStatusEventsCount[frameId].count) | 186 if (!InspectorTest.awaitedFrameStatusEventsCount[frameId].count) |
| 187 InspectorTest.awaitedFrameStatusEventsCount[frameId].callback(); | 187 InspectorTest.awaitedFrameStatusEventsCount[frameId].callback(); |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 | 190 |
| 191 InspectorTest.addSniffer(WebInspector.ApplicationCacheModel.prototype, "_fra
meManifestUpdated", addRecord, true); | 191 InspectorTest.addSniffer(SDK.ApplicationCacheModel.prototype, "_frameManifes
tUpdated", addRecord, true); |
| 192 } | 192 } |
| 193 | 193 |
| 194 InspectorTest.ensureFrameStatusEventsReceived = function(frameId, count, callbac
k) | 194 InspectorTest.ensureFrameStatusEventsReceived = function(frameId, count, callbac
k) |
| 195 { | 195 { |
| 196 var records = InspectorTest.applicationCacheStatusesRecords[frameId] || []; | 196 var records = InspectorTest.applicationCacheStatusesRecords[frameId] || []; |
| 197 var eventsLeft = count - records.length; | 197 var eventsLeft = count - records.length; |
| 198 | 198 |
| 199 if (!eventsLeft) { | 199 if (!eventsLeft) { |
| 200 callback(); | 200 callback(); |
| 201 return; | 201 return; |
| 202 } | 202 } |
| 203 | 203 |
| 204 if (!InspectorTest.awaitedFrameStatusEventsCount) | 204 if (!InspectorTest.awaitedFrameStatusEventsCount) |
| 205 InspectorTest.awaitedFrameStatusEventsCount = {}; | 205 InspectorTest.awaitedFrameStatusEventsCount = {}; |
| 206 InspectorTest.awaitedFrameStatusEventsCount[frameId] = { count: eventsLeft,
callback: callback }; | 206 InspectorTest.awaitedFrameStatusEventsCount[frameId] = { count: eventsLeft,
callback: callback }; |
| 207 } | 207 } |
| 208 | 208 |
| 209 }; | 209 }; |
| 210 | 210 |
| OLD | NEW |