servo: Merge #13784 - Issue 13363 - Step 1.2 of compiling event handler (from TooManyBees:13363-check-script-enabled); r=Ms2ger
authorJesse Kipp <esbe.v2@gmail.com>
Fri, 21 Oct 2016 09:24:05 -0500
changeset 339968 909df90f1caddc4b922b05937f369939ac7ba804
parent 339967 66dea736a35d7870cd314b460e9e140d1919a8a4
child 339969 a41f256faace00f5a0ecbbcba65999280b1d177a
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
servo: Merge #13784 - Issue 13363 - Step 1.2 of compiling event handler (from TooManyBees:13363-check-script-enabled); r=Ms2ger <!-- Please describe your changes on the following line: --> Adds the conditional to test that scripting is enabled in `EventTarget#get_compiled_event_handler`, and return `None` early if not. Adds tests for "scripting enabled" and "scripting disabled" cases. --- <!-- 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 #13363 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 776a1d9cacdd929e9ef6189bfffc9513e57b76ce
servo/components/script/dom/eventtarget.rs
--- a/servo/components/script/dom/eventtarget.rs
+++ b/servo/components/script/dom/eventtarget.rs
@@ -368,17 +368,20 @@ impl EventTarget {
                                       -> Option<CommonEventHandler> {
         // Step 1.1
         let element = self.downcast::<Element>();
         let document = match element {
             Some(element) => document_from_node(element),
             None => self.downcast::<Window>().unwrap().Document(),
         };
 
-        // TODO step 1.2 (browsing context/scripting enabled)
+        // Step 1.2
+        if !document.is_scripting_enabled() {
+            return None;
+        }
 
         // Step 1.3
         let body: Vec<u16> = handler.source.encode_utf16().collect();
 
         // TODO step 1.5 (form owner)
 
         // Step 1.6
         let window = document.window();