| <!DOCTYPE html> |
| |
| <!-- webkit-test-runner [ experimental:DarkModeCSSEnabled=true ] --> |
| |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| |
| <style> |
| #test1 { |
| color: text; |
| } |
| </style> |
| |
| <meta id="meta" name="color-scheme" content="light"> |
| |
| <div id="test1"></div> |
| |
| <script> |
| function test_prop(id, prop, expected) { |
| assert_equals(window.getComputedStyle(document.getElementById(id)).getPropertyValue(prop).trim(), expected); |
| } |
| |
| function test_color_is_white(id) { |
| test_prop("test1", "color", "rgb(255, 255, 255)"); |
| } |
| |
| function test_color_is_black(id) { |
| test_prop("test1", "color", "rgb(0, 0, 0)"); |
| } |
| |
| test(function() { |
| // The semantic text color should be black. |
| test_color_is_black("test1"); |
| }, "Element colors are correct in light color scheme with only light color scheme"); |
| |
| test(function() { |
| if (window.internals) |
| internals.settings.setUseDarkAppearance(true); |
| }, "Dark color scheme enabled"); |
| |
| test(function() { |
| // The semantic text color should be black, and not change. |
| test_color_is_black("test1"); |
| }, "Element colors are correct in dark color scheme with only light color scheme"); |
| |
| test(function() { |
| if (window.internals) |
| internals.settings.setUseDarkAppearance(false); |
| }, "Light color scheme enabled"); |
| |
| test(function() { |
| document.getElementById("meta").content = "light dark"; |
| }, "Color schemes changed to light and dark"); |
| |
| test(function() { |
| // The semantic text color should be black. |
| test_color_is_black("test1"); |
| }, "Element colors are correct in light color scheme with light and dark color scheme"); |
| |
| test(function() { |
| if (window.internals) |
| internals.settings.setUseDarkAppearance(true); |
| }, "Dark color scheme enabled"); |
| |
| test(function() { |
| // The semantic text color should be white. |
| test_color_is_white("test1"); |
| }, "Element colors are correct in dark color scheme with light and dark color scheme"); |
| |
| test(function() { |
| if (window.internals) |
| internals.settings.setUseDarkAppearance(false); |
| }, "Light color scheme enabled"); |
| |
| test(function() { |
| document.getElementById("meta").content = "dark"; |
| }, "Color schemes changed to dark"); |
| |
| test(function() { |
| // The semantic text color should be white. |
| test_color_is_white("test1"); |
| }, "Element colors are correct in light color scheme with only dark color scheme"); |
| |
| test(function() { |
| if (window.internals) |
| internals.settings.setUseDarkAppearance(true); |
| }, "Dark color scheme enabled"); |
| |
| test(function() { |
| // The semantic text color should be white still. |
| test_color_is_white("test1"); |
| }, "Element colors are correct in dark color scheme with only dark color scheme"); |
| |
| test(function() { |
| document.getElementById("meta").content = "\tlight foo "; |
| }, "Color schemes changed to light and a bogus value"); |
| |
| test(function() { |
| // The semantic text color should be black again. |
| test_color_is_black("test1"); |
| }, "Element colors are correct in dark color scheme with only light color scheme"); |
| |
| test(function() { |
| document.getElementById("meta").content = ""; |
| }, "Color schemes changed to empty value"); |
| |
| test(function() { |
| // The semantic text color should be black still. |
| test_color_is_black("test1"); |
| }, "Element colors are correct in dark color scheme with implicit light color scheme"); |
| |
| test(function() { |
| document.getElementById("meta").content = " light,dark "; |
| }, "Color schemes changed to light,dark"); |
| |
| test(function() { |
| // The semantic text color should be black now. |
| test_color_is_black("test1"); |
| }, "Element colors are in light color scheme since comma is not an allowed seperator"); |
| |
| test(function() { |
| document.getElementById("meta").content = "foo\vdark "; |
| }, "Color schemes changed to foo\\vdark"); |
| |
| test(function() { |
| // The semantic text color should be black still. |
| test_color_is_black("test1"); |
| }, "Element colors are in light color scheme since vertical tab is not an allowed seperator"); |
| |
| test(function() { |
| document.getElementById("meta").content = " foo\ndark"; |
| }, "Color schemes changed to a bogus value and dark"); |
| |
| test(function() { |
| // The semantic text color should be white still. |
| test_color_is_white("test1"); |
| }, "Element colors are correct in dark color scheme with dark color scheme"); |
| </script> |