servo: Merge #14589 - Reduce calls into arbitrary code with the ScriptThread::documents borrow held (from servo:harden-script); r=jdm+Ms2ger

Source-Repo: https://github.com/servo/servo
Source-Revision: 0c56499bdc5c92bac44f8c33e4781899c34d64e1
This commit is contained in:
Josh Matthews
2016-12-16 08:53:27 -08:00
parent 6bef4d878a
commit be969dee6a
4 changed files with 97 additions and 52 deletions

View File

@@ -0,0 +1,18 @@
fn main() {
// This should trigger an error.
match self.documents.borrow_mut() {
_ => {}
}
// This should trigger an error.
match self.documents.borrow() {
_ => {}
}
// This should not trigger an error.
match { self.documents.borrow().find_window(id) } {
=> {}
}
// This should not trigger an error.
match self.documents_status.borrow() {
=> {}
}
}

View File

@@ -141,6 +141,12 @@ class CheckTidiness(unittest.TestCase):
self.assertEqual('method declared in webidl is missing a comment with a specification link', errors.next()[2])
self.assertNoMoreErrors(errors)
def test_script_thread(self):
errors = tidy.collect_errors_for_files(iterFile('script_thread.rs'), [], [tidy.check_rust], print_text=False)
self.assertEqual('use a separate variable for the match expression', errors.next()[2])
self.assertEqual('use a separate variable for the match expression', errors.next()[2])
self.assertNoMoreErrors(errors)
def test_webidl(self):
errors = tidy.collect_errors_for_files(iterFile('spec.webidl'), [tidy.check_webidl_spec], [], print_text=False)
self.assertEqual('No specification link found.', errors.next()[2])