[evolution/wip/mcrha/webkit-jsc-api] Correct Evo.addRuleIntoStyleSheetDocument()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/mcrha/webkit-jsc-api] Correct Evo.addRuleIntoStyleSheetDocument()
- Date: Wed, 2 Oct 2019 12:49:58 +0000 (UTC)
commit af222b5052d7375f0136d85db9b591370d26e295
Author: Milan Crha <mcrha redhat com>
Date: Wed Oct 2 14:50:07 2019 +0200
Correct Evo.addRuleIntoStyleSheetDocument()
src/e-util/test-web-view.c | 23 ++++++++++++++---------
src/web-extensions/ext-utils.js | 2 ++
2 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/src/e-util/test-web-view.c b/src/e-util/test-web-view.c
index 655e23ab9e..1820978515 100644
--- a/src/e-util/test-web-view.c
+++ b/src/e-util/test-web-view.c
@@ -396,10 +396,7 @@ test_utils_jsc_call_string_and_verify (TestFixture *fixture,
value = test_utils_jsc_call_string_sync (fixture, script);
- if (!expected_value)
- g_assert_null (value);
- else
- g_assert_cmpstr (value, ==, expected_value);
+ g_assert_cmpstr (value, ==, expected_value);
g_free (value);
}
@@ -784,7 +781,8 @@ test_style_sheets (TestFixture *fixture)
"\n"
" for (ii = 0; ii < styles.cssRules.length; ii++) {\n"
" if (styles.cssRules[ii].selectorText == selector) {\n"
- " return styles.cssRules[ii].style.getPropertyValue(property_name);\n"
+ " var value =
styles.cssRules[ii].style.getPropertyValue(property_name);\n"
+ " return (!value || value == \"\") ? null : value;\n"
" }\n"
" }\n"
"\n"
@@ -808,9 +806,11 @@ test_style_sheets (TestFixture *fixture)
g_assert_cmpint (0, ==, test_utils_jsc_call_int32_sync (fixture, "Test.nStyles(\"frm1_1\")"));
g_assert_cmpint (0, ==, test_utils_jsc_call_int32_sync (fixture, "Test.nStyles(\"frm2\")"));
test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"\", \"sheet1\", \"body\",
\"color\")", "green");
- test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet2\", \"body\",
\"background-color\")", NULL);
+ test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet2\", \"input\",
\"background-color\")", NULL);
+ test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet2\", \"table\",
\"color\")", NULL);
- e_web_view_jsc_add_rule_into_style_sheet (fixture->web_view, "frm1_1", "sheet2", "body",
"background-color:black;", NULL);
+ e_web_view_jsc_add_rule_into_style_sheet (fixture->web_view, "frm1_1", "sheet2", "input",
"background-color:black;", NULL);
+ e_web_view_jsc_add_rule_into_style_sheet (fixture->web_view, "frm1_1", "sheet2", "table",
"color:green;", NULL);
test_utils_wait_noop (fixture);
g_assert_cmpint (2, ==, test_utils_jsc_call_int32_sync (fixture, "Test.nStyles(\"\")"));
@@ -818,13 +818,16 @@ test_style_sheets (TestFixture *fixture)
g_assert_cmpint (1, ==, test_utils_jsc_call_int32_sync (fixture, "Test.nStyles(\"frm1_1\")"));
g_assert_cmpint (0, ==, test_utils_jsc_call_int32_sync (fixture, "Test.nStyles(\"frm2\")"));
test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"\", \"sheet1\", \"body\",
\"color\")", "green");
- test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet2\", \"body\",
\"background-color\")", "black");
+ test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet2\", \"input\",
\"background-color\")", "black");
+ test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet2\", \"table\",
\"color\")", "green");
+ test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet2\", \"table\",
\"background-color\")", NULL);
test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"\", \"sheet3\", \"body\",
\"color\")", NULL);
test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1\", \"sheet3\", \"body\",
\"color\")", NULL);
test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet3\", \"body\",
\"color\")", NULL);
test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm2\", \"sheet3\", \"body\",
\"color\")", NULL);
e_web_view_jsc_add_rule_into_style_sheet (fixture->web_view, "*", "sheet3", "body", "color:orange;",
NULL);
+ e_web_view_jsc_add_rule_into_style_sheet (fixture->web_view, "frm1_1", "sheet2", "table", "color:red;
background-color:white;", NULL);
test_utils_wait_noop (fixture);
g_assert_cmpint (3, ==, test_utils_jsc_call_int32_sync (fixture, "Test.nStyles(\"\")"));
@@ -832,7 +835,9 @@ test_style_sheets (TestFixture *fixture)
g_assert_cmpint (2, ==, test_utils_jsc_call_int32_sync (fixture, "Test.nStyles(\"frm1_1\")"));
g_assert_cmpint (1, ==, test_utils_jsc_call_int32_sync (fixture, "Test.nStyles(\"frm2\")"));
test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"\", \"sheet1\", \"body\",
\"color\")", "green");
- test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet2\", \"body\",
\"background-color\")", "black");
+ test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet2\", \"input\",
\"background-color\")", "black");
+ test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet2\", \"table\",
\"color\")", "red");
+ test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet2\", \"table\",
\"background-color\")", "white");
test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"\", \"sheet3\", \"body\",
\"color\")", "orange");
test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1\", \"sheet3\", \"body\",
\"color\")", "orange");
test_utils_jsc_call_string_and_verify (fixture, "Test.getStyle(\"frm1_1\", \"sheet3\", \"body\",
\"color\")", "orange");
diff --git a/src/web-extensions/ext-utils.js b/src/web-extensions/ext-utils.js
index 7c8b4d5b48..a1183e2224 100644
--- a/src/web-extensions/ext-utils.js
+++ b/src/web-extensions/ext-utils.js
@@ -224,6 +224,8 @@ Evo.addRuleIntoStyleSheetDocument = function(doc, style_sheet_id, selector, styl
return;
}
}
+
+ styleobj.sheet.addRule(selector, style);
}
Evo.addRuleIntoStyleSheetDocumentRecursive = function(doc, style_sheet_id, selector, style)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]