aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/userscripts.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-07-21 04:08:49 -0500
committerGitHub <noreply@github.com>2016-07-21 04:08:49 -0500
commita39bd7db5ba26fa3c95e4bbbb5f1a358bc01965f (patch)
tree62a26e97151c44127322dc2ab66518f5ce7d5e77 /components/script/dom/userscripts.rs
parent4a77cbdbb2fc1a4f163171356a7f5340e1237317 (diff)
parentceb85795b1feed53121f9683cc34d2fd76cef761 (diff)
downloadservo-a39bd7db5ba26fa3c95e4bbbb5f1a358bc01965f.tar.gz
servo-a39bd7db5ba26fa3c95e4bbbb5f1a358bc01965f.zip
Auto merge of #12535 - Manishearth:try-resource, r=KiChjang
Use Result instead of panicking when the resource dir can't be found <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #12520 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because it's a refactoring <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12535) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/userscripts.rs')
-rw-r--r--components/script/dom/userscripts.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/components/script/dom/userscripts.rs b/components/script/dom/userscripts.rs
index 25490fb7726..e1c071e83c7 100644
--- a/components/script/dom/userscripts.rs
+++ b/components/script/dom/userscripts.rs
@@ -24,9 +24,12 @@ pub fn load_script(head: &HTMLHeadElement) {
let doc = doc.r();
let path = if &**path_str == "" {
- let mut p = resources_dir_path();
- p.push("user-agent-js");
- p
+ if let Ok(mut p) = resources_dir_path() {
+ p.push("user-agent-js");
+ p
+ } else {
+ return
+ }
} else {
PathBuf::from(path_str)
};