OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 ASSERT(resource->type() == Resource::Script); | 157 ASSERT(resource->type() == Resource::Script); |
158 ScriptResource* scriptResource = toScriptResource(resource); | 158 ScriptResource* scriptResource = toScriptResource(resource); |
159 String integrityAttr = m_element->fastGetAttribute(HTMLNames::integrityA
ttr); | 159 String integrityAttr = m_element->fastGetAttribute(HTMLNames::integrityA
ttr); |
160 | 160 |
161 // It is possible to get back a script resource with integrity metadata | 161 // It is possible to get back a script resource with integrity metadata |
162 // for a request with an empty integrity attribute. In that case, the | 162 // for a request with an empty integrity attribute. In that case, the |
163 // integrity check should be skipped, so this check ensures that the | 163 // integrity check should be skipped, so this check ensures that the |
164 // integrity attribute isn't empty in addition to checking if the | 164 // integrity attribute isn't empty in addition to checking if the |
165 // resource has empty integrity metadata. | 165 // resource has empty integrity metadata. |
166 if (!integrityAttr.isEmpty() && !scriptResource->integrityMetadata().isE
mpty()) { | 166 if (!integrityAttr.isEmpty() && !scriptResource->integrityMetadata().isE
mpty()) { |
167 if (!scriptResource->integrityAlreadyChecked() && resource->resource
Buffer()) { | 167 ScriptIntegrityDisposition disposition = scriptResource->integrityDi
sposition(); |
168 scriptResource->setIntegrityAlreadyChecked(true); | 168 if (disposition == ScriptIntegrityDisposition::Failed) { |
| 169 // TODO(jww): This should probably also generate a console |
| 170 // message identical to the one produced by |
| 171 // CheckSubresourceIntegrity below. See https://crbug.com/585267
. |
| 172 m_integrityFailure = true; |
| 173 } else if (disposition == ScriptIntegrityDisposition::NotChecked &&
resource->resourceBuffer()) { |
169 m_integrityFailure = !SubresourceIntegrity::CheckSubresourceInte
grity(scriptResource->integrityMetadata(), *m_element, resource->resourceBuffer(
)->data(), resource->resourceBuffer()->size(), resource->url(), *resource); | 174 m_integrityFailure = !SubresourceIntegrity::CheckSubresourceInte
grity(scriptResource->integrityMetadata(), *m_element, resource->resourceBuffer(
)->data(), resource->resourceBuffer()->size(), resource->url(), *resource); |
| 175 scriptResource->setIntegrityDisposition(m_integrityFailure ? Scr
iptIntegrityDisposition::Failed : ScriptIntegrityDisposition::Passed); |
170 } | 176 } |
171 } | 177 } |
172 } | 178 } |
173 | 179 |
174 if (m_streamer) | 180 if (m_streamer) |
175 m_streamer->notifyFinished(resource); | 181 m_streamer->notifyFinished(resource); |
176 } | 182 } |
177 | 183 |
178 void PendingScript::notifyAppendData(ScriptResource* resource) | 184 void PendingScript::notifyAppendData(ScriptResource* resource) |
179 { | 185 { |
(...skipping 30 matching lines...) Expand all Loading... |
210 bool PendingScript::isReady() const | 216 bool PendingScript::isReady() const |
211 { | 217 { |
212 if (resource() && !resource()->isLoaded()) | 218 if (resource() && !resource()->isLoaded()) |
213 return false; | 219 return false; |
214 if (m_streamer && !m_streamer->isFinished()) | 220 if (m_streamer && !m_streamer->isFinished()) |
215 return false; | 221 return false; |
216 return true; | 222 return true; |
217 } | 223 } |
218 | 224 |
219 } | 225 } |
OLD | NEW |