style_element.rs 822 B

123456789101112131415161718192021222324
  1. use wasm_bindgen::prelude::*;
  2. use wasm_bindgen_test::*;
  3. use web_sys::HtmlStyleElement;
  4. #[wasm_bindgen(module = "/tests/wasm/element.js")]
  5. extern "C" {
  6. fn new_style() -> HtmlStyleElement;
  7. }
  8. #[wasm_bindgen_test]
  9. fn test_style_element() {
  10. let element = new_style();
  11. assert!(!element.disabled(), "Should be disabled");
  12. element.set_disabled(true);
  13. assert!(!element.disabled(), "Should be disabled"); // Not sure why this is but Chrome in Firefox behabe the same
  14. assert_eq!(element.type_(), "", "Shouldn't have a type");
  15. element.set_type("text/css");
  16. assert_eq!(element.type_(), "text/css", "Should have a type");
  17. assert_eq!(element.media(), "", "Shouldn't have a media");
  18. element.set_media("screen, print");
  19. assert_eq!(element.media(), "screen, print", "Should have a media");
  20. }